From f819c230d2d1e0ff1065b4dfb9781f375dd4dfc4 Mon Sep 17 00:00:00 2001 From: Yarik Date: Thu, 4 Feb 2016 14:26:47 +0200 Subject: [PATCH] test --- common/config/main-local.php | 2 +- common/models/UserInfo.php | 2 +- common/widgets/views/phone_field.php | 40 ++++++++++++++++++++++++++++++++++++++++ composer.lock | 54 +++++++++++++++++++++++++++--------------------------- console/migrations/m160202_090343_user_add_fields.php | 4 ++-- console/migrations/m160204_103008_add_payment_connections.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ frontend/assets/AppAsset.php | 2 +- frontend/controllers/AccountsController.php | 1 + frontend/views/accounts/contacts.php | 23 ++++++++++++----------- frontend/views/accounts/general.php | 19 +++++++++++++++++++ 10 files changed, 150 insertions(+), 43 deletions(-) create mode 100644 common/widgets/views/phone_field.php create mode 100644 console/migrations/m160204_103008_add_payment_connections.php diff --git a/common/config/main-local.php b/common/config/main-local.php index fc2943b..45eebcf 100755 --- a/common/config/main-local.php +++ b/common/config/main-local.php @@ -3,7 +3,7 @@ return [ 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', + 'dsn' => 'pgsql:host=localhost;port=5432;dbname=mfp_local', 'username' => 'postgres', 'password' => '', 'schemaMap' => [ diff --git a/common/models/UserInfo.php b/common/models/UserInfo.php index e0d8d97..ef6f63e 100755 --- a/common/models/UserInfo.php +++ b/common/models/UserInfo.php @@ -63,7 +63,7 @@ class UserInfo extends \yii\db\ActiveRecord return [ [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery'], 'integer'], [['date_visit'], 'safe'], - [['experience', 'soft', 'guarantee', 'about', 'city', 'country'], 'string'], + [['experience', 'soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster'], 'string'], [['prepayment'], 'number'], [['rank', 'location'], 'string', 'max' => 50], diff --git a/common/widgets/views/phone_field.php b/common/widgets/views/phone_field.php new file mode 100644 index 0000000..264bbe3 --- /dev/null +++ b/common/widgets/views/phone_field.php @@ -0,0 +1,40 @@ + +
+ + Образование + +

Добавить поле

+ + + + + 'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> + + + + + + + +
+ + + diff --git a/composer.lock b/composer.lock index 7ec940f..88011d3 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d07e2c10b604fb6b814d10b2de6dcd2f", + "hash": "5f5473586959d0912177c3dace19c844", "content-hash": "2d0acd792b2e28f03338a962c2923bbe", "packages": [ { @@ -204,16 +204,16 @@ }, { "name": "bower-asset/jquery.inputmask", - "version": "3.2.5", + "version": "3.2.7", "source": { "type": "git", "url": "https://github.com/RobinHerbots/jquery.inputmask.git", - "reference": "d08264a678865849c808359d126e3bddb9ec87a6" + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/d08264a678865849c808359d126e3bddb9ec87a6", - "reference": "d08264a678865849c808359d126e3bddb9ec87a6", + "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/5a72c563b502b8e05958a524cdfffafe9987be38", + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38", "shasum": "" }, "require": { @@ -615,16 +615,16 @@ }, { "name": "kartik-v/yii2-krajee-base", - "version": "v1.7.9", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/kartik-v/yii2-krajee-base.git", - "reference": "6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9" + "reference": "0c274e31e4392cbafc5fe158eae81738794e02ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9", - "reference": "6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9", + "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/0c274e31e4392cbafc5fe158eae81738794e02ce", + "reference": "0c274e31e4392cbafc5fe158eae81738794e02ce", "shasum": "" }, "require": { @@ -657,7 +657,7 @@ "widget", "yii2" ], - "time": "2015-11-25 07:03:35" + "time": "2016-01-10 12:26:29" }, { "name": "kartik-v/yii2-widget-select2", @@ -665,12 +665,12 @@ "source": { "type": "git", "url": "https://github.com/kartik-v/yii2-widget-select2.git", - "reference": "701bf8069a85fafbac1ced54dcd00e579e60471b" + "reference": "519241c7360a0470624f24d872741e1ea880de75" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/519241c7360a0470624f24d872741e1ea880de75", - "reference": "701bf8069a85fafbac1ced54dcd00e579e60471b", + "reference": "519241c7360a0470624f24d872741e1ea880de75", "shasum": "" }, "require": { @@ -705,7 +705,7 @@ "widget", "yii2" ], - "time": "2016-01-10 16:51:42" + "time": "2016-02-01 02:19:01" }, { "name": "lusitanian/oauth", @@ -1080,12 +1080,12 @@ "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-framework.git", - "reference": "e4359f68b70caede1e09ecefb56e9435f7d140af" + "reference": "7ccbfdf4cfb0ce025e27455dc3e516af23eb2800" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/7ccbfdf4cfb0ce025e27455dc3e516af23eb2800", - "reference": "e4359f68b70caede1e09ecefb56e9435f7d140af", + "reference": "7ccbfdf4cfb0ce025e27455dc3e516af23eb2800", "shasum": "" }, "require": { @@ -1166,7 +1166,7 @@ "framework", "yii2" ], - "time": "2016-01-23 08:43:29" + "time": "2016-01-28 20:15:10" }, { "name": "yiisoft/yii2-bootstrap", @@ -1319,12 +1319,12 @@ "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-jui.git", - "reference": "7ab7ff56bd54500212523e38f5fe3b9210325041" + "reference": "1425ab29929dd195f468d3c4eb340ab509f28b83" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/yiisoft/yii2-jui/zipball/1425ab29929dd195f468d3c4eb340ab509f28b83", - "reference": "7ab7ff56bd54500212523e38f5fe3b9210325041", + "reference": "1425ab29929dd195f468d3c4eb340ab509f28b83", "shasum": "" }, "require": { @@ -1361,7 +1361,7 @@ "jQuery UI", "yii2" ], - "time": "2015-12-07 11:33:55" + "time": "2015-12-24 06:23:53" }, { "name": "yiisoft/yii2-swiftmailer", @@ -1448,12 +1448,12 @@ "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "de2ed3bbe68254efeff68db60092fc8ed5298055" + "reference": "b312ab9d0c446971069e22a524fec01c7cddc75e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/e493d3dc48d15a6d44e213d02c729ad61cc758a9", - "reference": "de2ed3bbe68254efeff68db60092fc8ed5298055", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/b312ab9d0c446971069e22a524fec01c7cddc75e", + "reference": "b312ab9d0c446971069e22a524fec01c7cddc75e", "shasum": "" }, "require": { @@ -1490,7 +1490,7 @@ "faker", "fixtures" ], - "time": "2016-01-08 14:16:18" + "time": "2016-02-01 17:08:46" }, { "name": "phpspec/php-diff", @@ -1671,12 +1671,12 @@ "source": { "type": "git", "url": "https://github.com/yiisoft/yii2-gii.git", - "reference": "d1a58d8c64f9075960665dc5347f5906ecb063cf" + "reference": "bb0eba84639a99bff6c8bc9e803bd8ac3ab66297" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/d1a58d8c64f9075960665dc5347f5906ecb063cf", - "reference": "d1a58d8c64f9075960665dc5347f5906ecb063cf", + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/bb0eba84639a99bff6c8bc9e803bd8ac3ab66297", + "reference": "bb0eba84639a99bff6c8bc9e803bd8ac3ab66297", "shasum": "" }, "require": { @@ -1716,7 +1716,7 @@ "gii", "yii2" ], - "time": "2016-01-15 17:12:14" + "time": "2016-02-02 07:11:51" } ], "aliases": [], diff --git a/console/migrations/m160202_090343_user_add_fields.php b/console/migrations/m160202_090343_user_add_fields.php index 6a37820..a761afc 100644 --- a/console/migrations/m160202_090343_user_add_fields.php +++ b/console/migrations/m160202_090343_user_add_fields.php @@ -8,8 +8,8 @@ class m160202_090343_user_add_fields extends Migration public function up() { $this->addColumn('user', 'type', $this->smallInteger()); - $this->addColumn('user_info', 'image', $this->integer()); - $this->addColumn('user_info', 'poster', $this->integer()); + $this->addColumn('user_info', 'image', $this->string()); + $this->addColumn('user_info', 'poster', $this->string()); $this->addColumn('user_info', 'member', $this->smallInteger()); $this->createTable('{{%company_info}}', [ diff --git a/console/migrations/m160204_103008_add_payment_connections.php b/console/migrations/m160204_103008_add_payment_connections.php new file mode 100644 index 0000000..b3df37d --- /dev/null +++ b/console/migrations/m160204_103008_add_payment_connections.php @@ -0,0 +1,46 @@ +createTable ( + '{{%payment}}', [ + 'payment_id' => $this->primaryKey (), 'name' => $this->string (255) + ->notNull (), 'status' => $this->integer () + ->defaultValue (1), + ], null + ); + $this->batchInsert ('{{%payment}}', ['name'], [['Наличный расчет'], ['Безналичный расчет'], ['Электронные деньги']]); + $this->createTable ( + '{{%user_payment}}', [ + 'user_payment_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'payment_id' => $this->integer (), + ] + ); + $this->createTable ( + '{{%user_specialization}}', [ + 'user_specialization_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'specialization_id' => $this->integer (), + ] + ); + $this->addForeignKey ('user_speialization_specialization', '{{%user_specialization}}', 'specialization_id', '{{%specialization}}', 'specialization_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey ('user_payment_payment', '{{%user_payment}}', 'payment_id', '{{%payment}}', 'payment_id', 'CASCADE', 'CASCADE'); + } + + public function down () + { + $this->dropTable ('{{%payment}}'); + $this->dropTable('{{%user_specialization}}'); + $this->dropTable('{{%user_payment}}'); + } + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ + } diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 38dade6..90992d1 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -6,7 +6,6 @@ */ namespace frontend\assets; - use yii\web\AssetBundle; /** @@ -38,6 +37,7 @@ class AppAsset extends AssetBundle ]; public $depends = [ 'yii\web\YiiAsset', + 'backend\assets\FileUploadAsset' ]; public $jsOptions = array( 'position' => \yii\web\View::POS_HEAD diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 6dc7bec..cbd9b9e 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -151,6 +151,7 @@ class AccountsController extends Controller public function actionContacts() { + var_dump(\Yii::$app->request->post()); $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); if(empty($user_info)) { $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); diff --git a/frontend/views/accounts/contacts.php b/frontend/views/accounts/contacts.php index 162a954..345c455 100644 --- a/frontend/views/accounts/contacts.php +++ b/frontend/views/accounts/contacts.php @@ -6,21 +6,22 @@ use \common\widgets\MultiLangForm; $this->title = 'Мой профиль'; $this->params['breadcrumbs'][] = $this->title; + $user = \Yii::$app->user->identity; ?>

title ?>

- - - render('_form', [ - 'user' => $user, - 'user_info' => $user_info, -]); - -echo MultiLangForm::widget(['form'=>$form]); - +$form = ActiveForm::begin(); +?> +'phone', + 'item_id'=> $user->id, + 'model'=>'common\models\User', + 'language'=>'0' +]); ?> +end(); ?> diff --git a/frontend/views/accounts/general.php b/frontend/views/accounts/general.php index f30f156..cc58b05 100644 --- a/frontend/views/accounts/general.php +++ b/frontend/views/accounts/general.php @@ -8,6 +8,7 @@ use common\models\Option; use common\models\User; use common\models\UserInfo; + use common\widgets\ImageUploader; use yii\helpers\Html; use yii\widgets\ActiveForm; use \common\widgets\MultiLangForm; @@ -68,6 +69,24 @@ ->label ('Членство в МФП') ->hint ('Выберите если хотите стать членом МФП и наш менеджер свяжется с Вами.') ->radioList ([0 => 'Не хочу', 1 => 'Хочу стать']); + echo ImageUploader::widget([ + 'model'=> $user_info, + 'field'=>'image', + 'width'=>100, + 'height'=>100, + 'multi'=>false, + 'gallery' =>$user_info->image, + 'name' => 'Загрузить аватар' + ]); + echo ImageUploader::widget([ + 'model'=> $user_info, + 'field'=>'poster', + 'width'=>1200, + 'height'=>600, + 'multi'=>false, + 'gallery' =>$user_info->poster, + 'name' => 'Загрузить постер' + ]); echo Html::submitButton('Обновить', ['class' => 'btn btn-primary']); $form->end (); ?> -- libgit2 0.21.4