Commit f819c230d2d1e0ff1065b4dfb9781f375dd4dfc4

Authored by Yarik
1 parent cea1aeb3

test

common/config/main-local.php
... ... @@ -3,7 +3,7 @@ return [
3 3 'components' => [
4 4 'db' => [
5 5 'class' => 'yii\db\Connection',
6   - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local',
  6 + 'dsn' => 'pgsql:host=localhost;port=5432;dbname=mfp_local',
7 7 'username' => 'postgres',
8 8 'password' => '',
9 9 'schemaMap' => [
... ...
common/models/UserInfo.php
... ... @@ -63,7 +63,7 @@ class UserInfo extends \yii\db\ActiveRecord
63 63 return [
64 64 [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery'], 'integer'],
65 65 [['date_visit'], 'safe'],
66   - [['experience', 'soft', 'guarantee', 'about', 'city', 'country'], 'string'],
  66 + [['experience', 'soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster'], 'string'],
67 67 [['prepayment'], 'number'],
68 68  
69 69 [['rank', 'location'], 'string', 'max' => 50],
... ...
common/widgets/views/phone_field.php 0 → 100644
  1 +<?php
  2 +use yii\helpers\Html;
  3 +?>
  4 +<fieldset>
  5 +
  6 + <legend>Образование</legend>
  7 +
  8 + <p class="btn btn-success add_field">Добавить поле</p>
  9 +
  10 +
  11 + <?php for($i=1; $i <= count($model); $i++):
  12 + $row = $i;
  13 + ?>
  14 +
  15 + <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?>
  16 + <input type="text" placeholder="Телефон" class="form-control" value="<?= isset($model[$i]['value']) ? $model[$i]['value'] : '' ?>" name="Fields[phone][<?=$row?>][0][phone]" />
  17 + <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>
  18 + <?= Html::endTag('div')?>
  19 + <?php endfor; ?>
  20 +
  21 +
  22 +
  23 +</fieldset>
  24 +<script>
  25 + $( document ).ready(function(){
  26 + var start_i = <?=$i?>;
  27 + $('.add_field').click(function(){
  28 + var block = $(this).parent('fieldset');
  29 + var block_id = $(this).parent('fieldset');
  30 + var sub_block = '<div class="form-group" >'+
  31 + '<input type="text" placeholder="Телефон" class="form-control" value="" name="Fields[phone]['+ start_i++ +'][0][phone]" />'+
  32 + '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>'+
  33 + '<div>';
  34 + block.append(sub_block);
  35 +
  36 + });
  37 + });
  38 +</script>
  39 +
  40 +
... ...
composer.lock
... ... @@ -4,7 +4,7 @@
4 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 5 "This file is @generated automatically"
6 6 ],
7   - "hash": "d07e2c10b604fb6b814d10b2de6dcd2f",
  7 + "hash": "5f5473586959d0912177c3dace19c844",
8 8 "content-hash": "2d0acd792b2e28f03338a962c2923bbe",
9 9 "packages": [
10 10 {
... ... @@ -204,16 +204,16 @@
204 204 },
205 205 {
206 206 "name": "bower-asset/jquery.inputmask",
207   - "version": "3.2.5",
  207 + "version": "3.2.7",
208 208 "source": {
209 209 "type": "git",
210 210 "url": "https://github.com/RobinHerbots/jquery.inputmask.git",
211   - "reference": "d08264a678865849c808359d126e3bddb9ec87a6"
  211 + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38"
212 212 },
213 213 "dist": {
214 214 "type": "zip",
215   - "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/d08264a678865849c808359d126e3bddb9ec87a6",
216   - "reference": "d08264a678865849c808359d126e3bddb9ec87a6",
  215 + "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/5a72c563b502b8e05958a524cdfffafe9987be38",
  216 + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38",
217 217 "shasum": ""
218 218 },
219 219 "require": {
... ... @@ -615,16 +615,16 @@
615 615 },
616 616 {
617 617 "name": "kartik-v/yii2-krajee-base",
618   - "version": "v1.7.9",
  618 + "version": "1.8.2",
619 619 "source": {
620 620 "type": "git",
621 621 "url": "https://github.com/kartik-v/yii2-krajee-base.git",
622   - "reference": "6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9"
  622 + "reference": "0c274e31e4392cbafc5fe158eae81738794e02ce"
623 623 },
624 624 "dist": {
625 625 "type": "zip",
626   - "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9",
627   - "reference": "6f10fd0a0bfccd729764c65fa65eb4ccf2cbade9",
  626 + "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/0c274e31e4392cbafc5fe158eae81738794e02ce",
  627 + "reference": "0c274e31e4392cbafc5fe158eae81738794e02ce",
628 628 "shasum": ""
629 629 },
630 630 "require": {
... ... @@ -657,7 +657,7 @@
657 657 "widget",
658 658 "yii2"
659 659 ],
660   - "time": "2015-11-25 07:03:35"
  660 + "time": "2016-01-10 12:26:29"
661 661 },
662 662 {
663 663 "name": "kartik-v/yii2-widget-select2",
... ... @@ -665,12 +665,12 @@
665 665 "source": {
666 666 "type": "git",
667 667 "url": "https://github.com/kartik-v/yii2-widget-select2.git",
668   - "reference": "701bf8069a85fafbac1ced54dcd00e579e60471b"
  668 + "reference": "519241c7360a0470624f24d872741e1ea880de75"
669 669 },
670 670 "dist": {
671 671 "type": "zip",
672 672 "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/519241c7360a0470624f24d872741e1ea880de75",
673   - "reference": "701bf8069a85fafbac1ced54dcd00e579e60471b",
  673 + "reference": "519241c7360a0470624f24d872741e1ea880de75",
674 674 "shasum": ""
675 675 },
676 676 "require": {
... ... @@ -705,7 +705,7 @@
705 705 "widget",
706 706 "yii2"
707 707 ],
708   - "time": "2016-01-10 16:51:42"
  708 + "time": "2016-02-01 02:19:01"
709 709 },
710 710 {
711 711 "name": "lusitanian/oauth",
... ... @@ -1080,12 +1080,12 @@
1080 1080 "source": {
1081 1081 "type": "git",
1082 1082 "url": "https://github.com/yiisoft/yii2-framework.git",
1083   - "reference": "e4359f68b70caede1e09ecefb56e9435f7d140af"
  1083 + "reference": "7ccbfdf4cfb0ce025e27455dc3e516af23eb2800"
1084 1084 },
1085 1085 "dist": {
1086 1086 "type": "zip",
1087 1087 "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/7ccbfdf4cfb0ce025e27455dc3e516af23eb2800",
1088   - "reference": "e4359f68b70caede1e09ecefb56e9435f7d140af",
  1088 + "reference": "7ccbfdf4cfb0ce025e27455dc3e516af23eb2800",
1089 1089 "shasum": ""
1090 1090 },
1091 1091 "require": {
... ... @@ -1166,7 +1166,7 @@
1166 1166 "framework",
1167 1167 "yii2"
1168 1168 ],
1169   - "time": "2016-01-23 08:43:29"
  1169 + "time": "2016-01-28 20:15:10"
1170 1170 },
1171 1171 {
1172 1172 "name": "yiisoft/yii2-bootstrap",
... ... @@ -1319,12 +1319,12 @@
1319 1319 "source": {
1320 1320 "type": "git",
1321 1321 "url": "https://github.com/yiisoft/yii2-jui.git",
1322   - "reference": "7ab7ff56bd54500212523e38f5fe3b9210325041"
  1322 + "reference": "1425ab29929dd195f468d3c4eb340ab509f28b83"
1323 1323 },
1324 1324 "dist": {
1325 1325 "type": "zip",
1326 1326 "url": "https://api.github.com/repos/yiisoft/yii2-jui/zipball/1425ab29929dd195f468d3c4eb340ab509f28b83",
1327   - "reference": "7ab7ff56bd54500212523e38f5fe3b9210325041",
  1327 + "reference": "1425ab29929dd195f468d3c4eb340ab509f28b83",
1328 1328 "shasum": ""
1329 1329 },
1330 1330 "require": {
... ... @@ -1361,7 +1361,7 @@
1361 1361 "jQuery UI",
1362 1362 "yii2"
1363 1363 ],
1364   - "time": "2015-12-07 11:33:55"
  1364 + "time": "2015-12-24 06:23:53"
1365 1365 },
1366 1366 {
1367 1367 "name": "yiisoft/yii2-swiftmailer",
... ... @@ -1448,12 +1448,12 @@
1448 1448 "source": {
1449 1449 "type": "git",
1450 1450 "url": "https://github.com/fzaninotto/Faker.git",
1451   - "reference": "de2ed3bbe68254efeff68db60092fc8ed5298055"
  1451 + "reference": "b312ab9d0c446971069e22a524fec01c7cddc75e"
1452 1452 },
1453 1453 "dist": {
1454 1454 "type": "zip",
1455   - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/e493d3dc48d15a6d44e213d02c729ad61cc758a9",
1456   - "reference": "de2ed3bbe68254efeff68db60092fc8ed5298055",
  1455 + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/b312ab9d0c446971069e22a524fec01c7cddc75e",
  1456 + "reference": "b312ab9d0c446971069e22a524fec01c7cddc75e",
1457 1457 "shasum": ""
1458 1458 },
1459 1459 "require": {
... ... @@ -1490,7 +1490,7 @@
1490 1490 "faker",
1491 1491 "fixtures"
1492 1492 ],
1493   - "time": "2016-01-08 14:16:18"
  1493 + "time": "2016-02-01 17:08:46"
1494 1494 },
1495 1495 {
1496 1496 "name": "phpspec/php-diff",
... ... @@ -1671,12 +1671,12 @@
1671 1671 "source": {
1672 1672 "type": "git",
1673 1673 "url": "https://github.com/yiisoft/yii2-gii.git",
1674   - "reference": "d1a58d8c64f9075960665dc5347f5906ecb063cf"
  1674 + "reference": "bb0eba84639a99bff6c8bc9e803bd8ac3ab66297"
1675 1675 },
1676 1676 "dist": {
1677 1677 "type": "zip",
1678   - "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/d1a58d8c64f9075960665dc5347f5906ecb063cf",
1679   - "reference": "d1a58d8c64f9075960665dc5347f5906ecb063cf",
  1678 + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/bb0eba84639a99bff6c8bc9e803bd8ac3ab66297",
  1679 + "reference": "bb0eba84639a99bff6c8bc9e803bd8ac3ab66297",
1680 1680 "shasum": ""
1681 1681 },
1682 1682 "require": {
... ... @@ -1716,7 +1716,7 @@
1716 1716 "gii",
1717 1717 "yii2"
1718 1718 ],
1719   - "time": "2016-01-15 17:12:14"
  1719 + "time": "2016-02-02 07:11:51"
1720 1720 }
1721 1721 ],
1722 1722 "aliases": [],
... ...
console/migrations/m160202_090343_user_add_fields.php
... ... @@ -8,8 +8,8 @@ class m160202_090343_user_add_fields extends Migration
8 8 public function up()
9 9 {
10 10 $this->addColumn('user', 'type', $this->smallInteger());
11   - $this->addColumn('user_info', 'image', $this->integer());
12   - $this->addColumn('user_info', 'poster', $this->integer());
  11 + $this->addColumn('user_info', 'image', $this->string());
  12 + $this->addColumn('user_info', 'poster', $this->string());
13 13 $this->addColumn('user_info', 'member', $this->smallInteger());
14 14  
15 15 $this->createTable('{{%company_info}}', [
... ...
console/migrations/m160204_103008_add_payment_connections.php 0 → 100644
  1 +<?php
  2 + use yii\db\Migration;
  3 +
  4 + class m160204_103008_add_payment_connections extends Migration
  5 + {
  6 + public function up ()
  7 + {
  8 + $this->createTable (
  9 + '{{%payment}}', [
  10 + 'payment_id' => $this->primaryKey (), 'name' => $this->string (255)
  11 + ->notNull (), 'status' => $this->integer ()
  12 + ->defaultValue (1),
  13 + ], null
  14 + );
  15 + $this->batchInsert ('{{%payment}}', ['name'], [['Наличный расчет'], ['Безналичный расчет'], ['Электронные деньги']]);
  16 + $this->createTable (
  17 + '{{%user_payment}}', [
  18 + 'user_payment_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'payment_id' => $this->integer (),
  19 + ]
  20 + );
  21 + $this->createTable (
  22 + '{{%user_specialization}}', [
  23 + 'user_specialization_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'specialization_id' => $this->integer (),
  24 + ]
  25 + );
  26 + $this->addForeignKey ('user_speialization_specialization', '{{%user_specialization}}', 'specialization_id', '{{%specialization}}', 'specialization_id', 'CASCADE', 'CASCADE');
  27 + $this->addForeignKey ('user_payment_payment', '{{%user_payment}}', 'payment_id', '{{%payment}}', 'payment_id', 'CASCADE', 'CASCADE');
  28 + }
  29 +
  30 + public function down ()
  31 + {
  32 + $this->dropTable ('{{%payment}}');
  33 + $this->dropTable('{{%user_specialization}}');
  34 + $this->dropTable('{{%user_payment}}');
  35 + }
  36 + /*
  37 + // Use safeUp/safeDown to run migration code within a transaction
  38 + public function safeUp()
  39 + {
  40 + }
  41 +
  42 + public function safeDown()
  43 + {
  44 + }
  45 + */
  46 + }
... ...
frontend/assets/AppAsset.php
... ... @@ -6,7 +6,6 @@
6 6 */
7 7  
8 8 namespace frontend\assets;
9   -
10 9 use yii\web\AssetBundle;
11 10  
12 11 /**
... ... @@ -38,6 +37,7 @@ class AppAsset extends AssetBundle
38 37 ];
39 38 public $depends = [
40 39 'yii\web\YiiAsset',
  40 + 'backend\assets\FileUploadAsset'
41 41 ];
42 42 public $jsOptions = array(
43 43 'position' => \yii\web\View::POS_HEAD
... ...
frontend/controllers/AccountsController.php
... ... @@ -151,6 +151,7 @@ class AccountsController extends Controller
151 151  
152 152 public function actionContacts()
153 153 {
  154 + var_dump(\Yii::$app->request->post());
154 155 $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one();
155 156 if(empty($user_info)) {
156 157 $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]);
... ...
frontend/views/accounts/contacts.php
... ... @@ -6,21 +6,22 @@ use \common\widgets\MultiLangForm;
6 6  
7 7 $this->title = 'Мой профиль';
8 8 $this->params['breadcrumbs'][] = $this->title;
  9 + $user = \Yii::$app->user->identity;
9 10 ?>
10 11  
11 12 <h1><?= $this->title ?></h1>
12   -
13   -
14   -
15 13 <?php
16   -
17   -$form = $this->render('_form', [
18   - 'user' => $user,
19   - 'user_info' => $user_info,
20   -]);
21   -
22   -echo MultiLangForm::widget(['form'=>$form]);
23   -
  14 +$form = ActiveForm::begin();
  15 +?>
  16 +<?= \common\widgets\FieldEditor::widget([
  17 + 'template'=>'phone',
  18 + 'item_id'=> $user->id,
  19 + 'model'=>'common\models\User',
  20 + 'language'=>'0'
  21 +]); ?>
  22 +<?php
  23 + echo Html::submitButton('submit');
  24 + $form->end();
24 25 ?>
25 26  
26 27  
... ...
frontend/views/accounts/general.php
... ... @@ -8,6 +8,7 @@
8 8 use common\models\Option;
9 9 use common\models\User;
10 10 use common\models\UserInfo;
  11 + use common\widgets\ImageUploader;
11 12 use yii\helpers\Html;
12 13 use yii\widgets\ActiveForm;
13 14 use \common\widgets\MultiLangForm;
... ... @@ -68,6 +69,24 @@
68 69 ->label ('Членство в МФП')
69 70 ->hint ('Выберите если хотите стать членом МФП и наш менеджер свяжется с Вами.')
70 71 ->radioList ([0 => 'Не хочу', 1 => 'Хочу стать']);
  72 + echo ImageUploader::widget([
  73 + 'model'=> $user_info,
  74 + 'field'=>'image',
  75 + 'width'=>100,
  76 + 'height'=>100,
  77 + 'multi'=>false,
  78 + 'gallery' =>$user_info->image,
  79 + 'name' => 'Загрузить аватар'
  80 + ]);
  81 + echo ImageUploader::widget([
  82 + 'model'=> $user_info,
  83 + 'field'=>'poster',
  84 + 'width'=>1200,
  85 + 'height'=>600,
  86 + 'multi'=>false,
  87 + 'gallery' =>$user_info->poster,
  88 + 'name' => 'Загрузить постер'
  89 + ]);
71 90 echo Html::submitButton('Обновить', ['class' => 'btn btn-primary']);
72 91 $form->end ();
73 92 ?>
... ...