Commit 9bb0160de4c9f22b8a0afe64958b30703e5af9e4

Authored by Administrator
1 parent 161155ac

09.02.16

common/models/Fields.php
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace common\models; 3 namespace common\models;
4 4
5 use Yii; 5 use Yii;
  6 +use yii\helpers\ArrayHelper;
6 7
7 /** 8 /**
8 * This is the model class for table "{{%fields}}". 9 * This is the model class for table "{{%fields}}".
@@ -55,7 +56,11 @@ class Fields extends \yii\db\ActiveRecord @@ -55,7 +56,11 @@ class Fields extends \yii\db\ActiveRecord
55 } 56 }
56 57
57 public static function getData($id, $model, $type){ 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,7 +43,7 @@
43 var block_id = $ (this) 43 var block_id = $ (this)
44 .parent ('fieldset'); 44 .parent ('fieldset');
45 var sub_block = '<div class="form-group" >' + 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 '<input type="number" class="form-control" value="" name="Fields[courses][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' + 47 '<input type="number" class="form-control" value="" name="Fields[courses][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' +
48 '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' + 48 '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' +
49 '<div>'; 49 '<div>';
common/widgets/views/development_field.php
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 var block_id = $ (this) 42 var block_id = $ (this)
43 .parent ('fieldset'); 43 .parent ('fieldset');
44 var sub_block = '<div class="form-group" >' + 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 '<input type="number" class="form-control" value="" name="Fields[development][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' + 46 '<input type="number" class="form-control" value="" name="Fields[development][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' +
47 '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' + 47 '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' +
48 '<div>'; 48 '<div>';
common/widgets/views/education_field.php
@@ -55,9 +55,9 @@ @@ -55,9 +55,9 @@
55 var block_id = $ (this) 55 var block_id = $ (this)
56 .parent ('fieldset'); 56 .parent ('fieldset');
57 var sub_block = '<div class="form-group" >' + 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 '<label for="edu-name-' + start_label_<?=$this->context->id?> +'"></label>'+ 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 '<label for="edu-to-' + start_label_<?=$this->context->id?> +'"></label>'+ 61 '<label for="edu-to-' + start_label_<?=$this->context->id?> +'"></label>'+
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]" />' + 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 '<label for="edu-out-' + start_label_<?=$this->context->id?> +'"></label>'+ 63 '<label for="edu-out-' + start_label_<?=$this->context->id?> +'"></label>'+
frontend/config/main.php
@@ -64,6 +64,7 @@ return [ @@ -64,6 +64,7 @@ return [
64 'showScriptName' => false, 64 'showScriptName' => false,
65 'rules' => [ 65 'rules' => [
66 'landing/<view:[\w-]+>' => 'landing/view', 66 'landing/<view:[\w-]+>' => 'landing/view',
  67 + 'performer/common/<performer_id:[\w-]+>' => 'performer/common',
67 ] 68 ]
68 ], 69 ],
69 ], 70 ],
frontend/controllers/PerformerController.php
@@ -48,24 +48,28 @@ class PerformerController extends Controller @@ -48,24 +48,28 @@ class PerformerController extends Controller
48 ]; 48 ];
49 } 49 }
50 50
51 - /**  
52 - * @var $user common\models\User  
53 - */ 51 +
54 public function actionIndex() 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 public function actionPortfolio(/*$performer_id*/) 75 public function actionPortfolio(/*$performer_id*/)
frontend/views/performer/common.php
@@ -14,27 +14,13 @@ $this-&gt;title = &#39;My Yii Application&#39;; @@ -14,27 +14,13 @@ $this-&gt;title = &#39;My Yii Application&#39;;
14 </div> 14 </div>
15 <a href="#" class="profile-see-all"></a> 15 <a href="#" class="profile-see-all"></a>
16 <div class="proektant-profile-courses-wr style"> 16 <div class="proektant-profile-courses-wr style">
  17 + <?php foreach( $educations as $education):?>
17 <div class="proektant-profile-courses"> 18 <div class="proektant-profile-courses">
18 <div class="proektant-profile-courses-title">Образование:</div> 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 </div> 22 </div>
  23 + <?php endforeach; ?>
38 </div> 24 </div>
39 25
40 <div class="proektant-profile-statistic-wr style"> 26 <div class="proektant-profile-statistic-wr style">