Commit cd6bd007c9db36ea49d3f647f4939129dfa73e04
1 parent
317dd52a
test
Showing
7 changed files
with
57 additions
and
10 deletions
Show diff stats
common/config/main-local.php
| @@ -3,9 +3,9 @@ return [ | @@ -3,9 +3,9 @@ return [ | ||
| 3 | 'components' => [ | 3 | 'components' => [ |
| 4 | 'db' => [ | 4 | 'db' => [ |
| 5 | 'class' => 'yii\db\Connection', | 5 | 'class' => 'yii\db\Connection', |
| 6 | - 'dsn' => 'pgsql:host=195.248.225.149;port=5432;dbname=mfp', | ||
| 7 | - 'username' => 'test33', | ||
| 8 | - 'password' => 'E4q2N7i9', | 6 | + 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', |
| 7 | + 'username' => 'postgres', | ||
| 8 | + 'password' => '', | ||
| 9 | 'schemaMap' => [ | 9 | 'schemaMap' => [ |
| 10 | 'pgsql'=> [ | 10 | 'pgsql'=> [ |
| 11 | 'class'=>'yii\db\pgsql\Schema', | 11 | 'class'=>'yii\db\pgsql\Schema', |
common/models/OptionHelper.php
| @@ -28,7 +28,7 @@ class OptionHelper extends Model | @@ -28,7 +28,7 @@ class OptionHelper extends Model | ||
| 28 | throw new InvalidParamException(Yii::t('app', 'Must be 1-3')); | 28 | throw new InvalidParamException(Yii::t('app', 'Must be 1-3')); |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| 31 | - | 31 | + /* |
| 32 | public function createOptions($user_id) | 32 | public function createOptions($user_id) |
| 33 | { | 33 | { |
| 34 | if($rows_delete = \Yii::$app->db->createCommand()->delete('option', ['model' => 'common\models\User', 'model_id' => $user_id])->execute()) { | 34 | if($rows_delete = \Yii::$app->db->createCommand()->delete('option', ['model' => 'common\models\User', 'model_id' => $user_id])->execute()) { |
| @@ -36,7 +36,46 @@ class OptionHelper extends Model | @@ -36,7 +36,46 @@ class OptionHelper extends Model | ||
| 36 | } else { | 36 | } else { |
| 37 | Yii::trace( "No rows has been deleted" ); | 37 | Yii::trace( "No rows has been deleted" ); |
| 38 | } | 38 | } |
| 39 | - //Yii::$app->db->createCommand()->batchInsert('option', ['model', 'model_id', 'name', 'template', 'option_pid'], [['common\models\User', $user_id, 'about', '']]) | 39 | + $rows_insert = Yii::$app->db->createCommand()->batchInsert( |
| 40 | + 'option', | ||
| 41 | + ['model', 'model_id', 'name', 'template'], | ||
| 42 | + [ | ||
| 43 | + ['common\models\User', $user_id, 'education', '{"template":"empty","params":{"multiple":true}}'], | ||
| 44 | + ['common\models\User', $user_id, 'development', '{"template":"empty","params":{"multiple":true}}'], | ||
| 45 | + ['common\models\User', $user_id, 'courses', '{"template":"empty","params":{"multiple":true}}'], | ||
| 46 | + ['common\models\User', $user_id, 'jobs', '{"template":"empty","params":{"multiple":true}}'], | ||
| 47 | + ['common\models\User', $user_id, 'social', '{"template":"empty","params":{"multiple":true}}'], | ||
| 48 | + ] | ||
| 49 | + )->execute(); | ||
| 50 | + Yii::trace( $rows_insert . " rows has been inserted" ); | ||
| 51 | + $parent_rows = Option::find()->where(['model' => 'common\models\User', 'model_id' => $user_id, 'option_pid' => NULL])->indexBy('name')->all(); | ||
| 52 | + $rows_insert = Yii::$app->db->createCommand()->batchInsert( | ||
| 53 | + 'option', | ||
| 54 | + ['model', 'model_id', 'name', 'template', 'option_pid'], | ||
| 55 | + [ | ||
| 56 | + ['common\models\User', $user_id, 'year_from', '{"template":"input","params":{"type":"number"}}', $parent_rows['education']->option_id], | ||
| 57 | + ['common\models\User', $user_id, 'year_to', '{"template":"input","params":{"type":"number"}}', $parent_rows['education']->option_id], | ||
| 58 | + ['common\models\User', $user_id, 'place', '{"template":"textInput","params":[]}', $parent_rows['education']->option_id], | ||
| 59 | + ['common\models\User', $user_id, 'year', '{"template":"input","params":{"type":"number"}}', $parent_rows['development']->option_id], | ||
| 60 | + ['common\models\User', $user_id, 'name', '{"template":"textInput","params":[]}', $parent_rows['development']->option_id], | ||
| 61 | + ['common\models\User', $user_id, 'year', '{"template":"input","params":{"type":"number"}}', $parent_rows['courses']->option_id], | ||
| 62 | + ['common\models\User', $user_id, 'name', '{"template":"textInput","params":[]}', $parent_rows['courses']->option_id], | ||
| 63 | + ['common\models\User', $user_id, 'country', '{"template":"textInput","params":[]}', $parent_rows['jobs']->option_id], | ||
| 64 | + ['common\models\User', $user_id, 'date_from', '{"template":"datePicker","params":{"dateFormat":"dd-MM-yyyy"}}', $parent_rows['jobs']->option_id], | ||
| 65 | + ['common\models\User', $user_id, 'date_to', '{"template":"datePicker","params":{"dateFormat":"dd-MM-yyyy"}}', $parent_rows['jobs']->option_id], | ||
| 66 | + ['common\models\User', $user_id, 'type', '{"template":"textInput","params":[]}', $parent_rows['jobs']->option_id], | ||
| 67 | + ['common\models\User', $user_id, 'team', '{"template":"input","params":{"type":"number"}}', $parent_rows['jobs']->option_id], | ||
| 68 | + ['common\models\User', $user_id, 'time', '{"template":"input","params":{"type":"number"}}', $parent_rows['jobs']->option_id], | ||
| 69 | + ['common\models\User', $user_id, 'percent', '{"template":"input","params":{"type":"number"}}', $parent_rows['jobs']->option_id], | ||
| 70 | + ['common\models\User', $user_id, 'position', '{"template":"textInput","params":[]}', $parent_rows['jobs']->option_id], | ||
| 71 | + ['common\models\User', $user_id, 'facebook', '{"template":"textInput","params":[]}', $parent_rows['social']->option_id], | ||
| 72 | + ['common\models\User', $user_id, 'twitter', '{"template":"textInput","params":[]}', $parent_rows['social']->option_id], | ||
| 73 | + ['common\models\User', $user_id, 'linkedin', '{"template":"textInput","params":[]}', $parent_rows['social']->option_id], | ||
| 74 | + ['common\models\User', $user_id, 'vk', '{"template":"textInput","params":[]}', $parent_rows['social']->option_id], | ||
| 75 | + ] | ||
| 76 | + )->execute(); | ||
| 40 | } | 77 | } |
| 41 | 78 | ||
| 79 | + */ | ||
| 80 | + | ||
| 42 | } | 81 | } |
common/models/User.php
| @@ -253,4 +253,10 @@ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface | @@ -253,4 +253,10 @@ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface | ||
| 253 | return $result; | 253 | return $result; |
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| 256 | + | ||
| 257 | + public function afterSave ($insert, $changedAttributes) | ||
| 258 | + { | ||
| 259 | + parent::afterSave ($insert, $changedAttributes); | ||
| 260 | + \Yii::$app->options->createOptions($this->id); | ||
| 261 | + } | ||
| 256 | } | 262 | } |
frontend/assets/AdminAsset.php
| @@ -23,7 +23,7 @@ class AdminAsset extends AssetBundle | @@ -23,7 +23,7 @@ class AdminAsset extends AssetBundle | ||
| 23 | ]; | 23 | ]; |
| 24 | public $js = [ | 24 | public $js = [ |
| 25 | 'js/script.js', | 25 | 'js/script.js', |
| 26 | - 'http://maps.google.com/maps/api/js?sensor=false', | 26 | + //'http://maps.google.com/maps/api/js?sensor=false', |
| 27 | 'js/markerclusterer.js', | 27 | 'js/markerclusterer.js', |
| 28 | 'js/jquery.scrollbox.min.js', | 28 | 'js/jquery.scrollbox.min.js', |
| 29 | 'js/slider.js', | 29 | 'js/slider.js', |
frontend/assets/AppAsset.php
| @@ -23,7 +23,7 @@ class AppAsset extends AssetBundle | @@ -23,7 +23,7 @@ class AppAsset extends AssetBundle | ||
| 23 | ]; | 23 | ]; |
| 24 | public $js = [ | 24 | public $js = [ |
| 25 | 'js/script.js', | 25 | 'js/script.js', |
| 26 | - 'http://maps.google.com/maps/api/js?sensor=false', | 26 | + //'http://maps.google.com/maps/api/js?sensor=false', |
| 27 | 'js/markerclusterer.js', | 27 | 'js/markerclusterer.js', |
| 28 | 'js/jquery.scrollbox.min.js', | 28 | 'js/jquery.scrollbox.min.js', |
| 29 | 'js/slider.js', | 29 | 'js/slider.js', |
frontend/views/accounts/cabinet.php
| 1 | <?php | 1 | <?php |
| 2 | + use common\models\Option; | ||
| 2 | 3 | ||
| 3 | -$this->title = 'Мой профиль'; | 4 | + $this->title = 'Мой профиль'; |
| 4 | $this->params['breadcrumbs'][] = $this->title; | 5 | $this->params['breadcrumbs'][] = $this->title; |
| 5 | ?> | 6 | ?> |
| 6 | 7 | ||
| 7 | -<h1><?= $this->title ?></h1> | ||
| 8 | \ No newline at end of file | 8 | \ No newline at end of file |
| 9 | +<h1><?= $this->title ?></h1> | ||
| 10 | + |
frontend/views/layouts/main.php
| @@ -17,7 +17,7 @@ AppAsset::register($this); | @@ -17,7 +17,7 @@ AppAsset::register($this); | ||
| 17 | <html lang="<?= Yii::$app->language ?>"> | 17 | <html lang="<?= Yii::$app->language ?>"> |
| 18 | 18 | ||
| 19 | <head> | 19 | <head> |
| 20 | - <link href='https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin' rel='stylesheet' type='text/css'> | 20 | + <!--<link href='https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin' rel='stylesheet' type='text/css'>--> |
| 21 | <meta charset="<?= Yii::$app->charset ?>"> | 21 | <meta charset="<?= Yii::$app->charset ?>"> |
| 22 | 22 | ||
| 23 | <?= Html::csrfMetaTags() ?> | 23 | <?= Html::csrfMetaTags() ?> |