Commit d6922c7cf59ca53b8b1069c3f6f0955086bdb6d7
Merge remote-tracking branch 'origin/master'
Showing
11 changed files
with
150 additions
and
32 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=localhost;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/UserInfo.php
@@ -63,7 +63,7 @@ class UserInfo extends \yii\db\ActiveRecord | @@ -63,7 +63,7 @@ class UserInfo extends \yii\db\ActiveRecord | ||
63 | return [ | 63 | return [ |
64 | [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery'], 'integer'], | 64 | [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery'], 'integer'], |
65 | [['date_visit'], 'safe'], | 65 | [['date_visit'], 'safe'], |
66 | - [['experience', 'soft', 'guarantee', 'about', 'city', 'country'], 'string'], | 66 | + [['experience', 'soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster'], 'string'], |
67 | [['prepayment'], 'number'], | 67 | [['prepayment'], 'number'], |
68 | 68 | ||
69 | [['rank', 'location'], 'string', 'max' => 50], | 69 | [['rank', 'location'], 'string', 'max' => 50], |
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,7 +4,7 @@ | ||
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | "This file is @generated automatically" | 5 | "This file is @generated automatically" |
6 | ], | 6 | ], |
7 | - "hash": "d07e2c10b604fb6b814d10b2de6dcd2f", | 7 | + "hash": "5f5473586959d0912177c3dace19c844", |
8 | "content-hash": "2d0acd792b2e28f03338a962c2923bbe", | 8 | "content-hash": "2d0acd792b2e28f03338a962c2923bbe", |
9 | "packages": [ | 9 | "packages": [ |
10 | { | 10 | { |
console/migrations/m160202_090343_user_add_fields.php
@@ -8,8 +8,8 @@ class m160202_090343_user_add_fields extends Migration | @@ -8,8 +8,8 @@ class m160202_090343_user_add_fields extends Migration | ||
8 | public function up() | 8 | public function up() |
9 | { | 9 | { |
10 | $this->addColumn('user', 'type', $this->smallInteger()); | 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 | $this->addColumn('user_info', 'member', $this->smallInteger()); | 13 | $this->addColumn('user_info', 'member', $this->smallInteger()); |
14 | 14 | ||
15 | $this->createTable('{{%company_info}}', [ | 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,7 +6,6 @@ | ||
6 | */ | 6 | */ |
7 | 7 | ||
8 | namespace frontend\assets; | 8 | namespace frontend\assets; |
9 | - | ||
10 | use yii\web\AssetBundle; | 9 | use yii\web\AssetBundle; |
11 | 10 | ||
12 | /** | 11 | /** |
@@ -39,6 +38,7 @@ class AppAsset extends AssetBundle | @@ -39,6 +38,7 @@ class AppAsset extends AssetBundle | ||
39 | ]; | 38 | ]; |
40 | public $depends = [ | 39 | public $depends = [ |
41 | 'yii\web\YiiAsset', | 40 | 'yii\web\YiiAsset', |
41 | + 'backend\assets\FileUploadAsset' | ||
42 | ]; | 42 | ]; |
43 | public $jsOptions = array( | 43 | public $jsOptions = array( |
44 | 'position' => \yii\web\View::POS_HEAD | 44 | 'position' => \yii\web\View::POS_HEAD |
frontend/controllers/AccountsController.php
@@ -150,6 +150,7 @@ class AccountsController extends Controller | @@ -150,6 +150,7 @@ class AccountsController extends Controller | ||
150 | 150 | ||
151 | public function actionContacts() | 151 | public function actionContacts() |
152 | { | 152 | { |
153 | + var_dump(\Yii::$app->request->post()); | ||
153 | $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); | 154 | $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); |
154 | if(empty($user_info)) { | 155 | if(empty($user_info)) { |
155 | $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); | 156 | $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); |
@@ -169,16 +170,29 @@ class AccountsController extends Controller | @@ -169,16 +170,29 @@ class AccountsController extends Controller | ||
169 | 170 | ||
170 | public function actionEmployment() | 171 | public function actionEmployment() |
171 | { | 172 | { |
172 | - $job = Job::find()->where(['user_id' => \Yii::$app->user->getId()])->orderBy(['current' => SORT_DESC])->all(); | ||
173 | - if(empty($job)) { | ||
174 | - $job[] = new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 0]); | ||
175 | - } | ||
176 | - if(!$job[0]->current) { | ||
177 | - array_unshift($job, new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 1])); | ||
178 | - } | ||
179 | - if(!empty(\Yii::$app->request->post())) { | ||
180 | - var_dump(\Yii::$app->request->post()); | ||
181 | - die(); | 173 | + $post = \Yii::$app->request->post(); |
174 | + if(!empty($post)) { | ||
175 | + $job = []; | ||
176 | + for($i = 0; $i < count($post['Job']); $i++) { | ||
177 | + $job[$i] = new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 0]); | ||
178 | + } | ||
179 | + if(Job::loadMultiple($job, $post)) { | ||
180 | + $job[0]->current = 1; | ||
181 | + if(Job::validateMultiple($job)) { | ||
182 | + Job::deleteAll(['user_id' => \Yii::$app->user->getId()]); | ||
183 | + foreach($job as $onejob) { | ||
184 | + $onejob->save(false); | ||
185 | + } | ||
186 | + } | ||
187 | + } | ||
188 | + } else { | ||
189 | + $job = Job::find()->where(['user_id' => \Yii::$app->user->getId()])->orderBy(['current' => SORT_DESC])->all(); | ||
190 | + if(empty($job)) { | ||
191 | + $job[] = new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 0]); | ||
192 | + } | ||
193 | + if(!$job[0]->current) { | ||
194 | + array_unshift($job, new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 1])); | ||
195 | + } | ||
182 | } | 196 | } |
183 | return $this->render('employment', ['job' => $job]); | 197 | return $this->render('employment', ['job' => $job]); |
184 | } | 198 | } |
frontend/views/accounts/contacts.php
@@ -6,21 +6,22 @@ use \common\widgets\MultiLangForm; | @@ -6,21 +6,22 @@ use \common\widgets\MultiLangForm; | ||
6 | 6 | ||
7 | $this->title = 'Мой профиль'; | 7 | $this->title = 'Мой профиль'; |
8 | $this->params['breadcrumbs'][] = $this->title; | 8 | $this->params['breadcrumbs'][] = $this->title; |
9 | + $user = \Yii::$app->user->identity; | ||
9 | ?> | 10 | ?> |
10 | 11 | ||
11 | <h1><?= $this->title ?></h1> | 12 | <h1><?= $this->title ?></h1> |
12 | - | ||
13 | - | ||
14 | - | ||
15 | <?php | 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/employment.php
@@ -19,9 +19,6 @@ | @@ -19,9 +19,6 @@ | ||
19 | <p>Текущее место работы:</p> | 19 | <p>Текущее место работы:</p> |
20 | <div class="current_job_inputs"> | 20 | <div class="current_job_inputs"> |
21 | <?php | 21 | <?php |
22 | - echo $form->field ($current, '[0]current') | ||
23 | - ->label (false) | ||
24 | - ->hiddenInput (['value' => 1]); | ||
25 | echo $form->field ($current, '[0]name') | 22 | echo $form->field ($current, '[0]name') |
26 | ->label ('Название') | 23 | ->label ('Название') |
27 | ->textInput (); | 24 | ->textInput (); |
@@ -76,6 +73,7 @@ | @@ -76,6 +73,7 @@ | ||
76 | </div> | 73 | </div> |
77 | <?php | 74 | <?php |
78 | echo Html::button('Добавить место работы', ['id' => 'add_job_button']); | 75 | echo Html::button('Добавить место работы', ['id' => 'add_job_button']); |
76 | + echo Html::submitButton('Обновить'); | ||
79 | $form->end (); | 77 | $form->end (); |
80 | ?> | 78 | ?> |
81 | <script> | 79 | <script> |
frontend/views/accounts/general.php
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | use common\models\Option; | 8 | use common\models\Option; |
9 | use common\models\User; | 9 | use common\models\User; |
10 | use common\models\UserInfo; | 10 | use common\models\UserInfo; |
11 | + use common\widgets\ImageUploader; | ||
11 | use yii\helpers\Html; | 12 | use yii\helpers\Html; |
12 | use yii\widgets\ActiveForm; | 13 | use yii\widgets\ActiveForm; |
13 | use \common\widgets\MultiLangForm; | 14 | use \common\widgets\MultiLangForm; |
@@ -68,6 +69,24 @@ | @@ -68,6 +69,24 @@ | ||
68 | ->label ('Членство в МФП') | 69 | ->label ('Членство в МФП') |
69 | ->hint ('Выберите если хотите стать членом МФП и наш менеджер свяжется с Вами.') | 70 | ->hint ('Выберите если хотите стать членом МФП и наш менеджер свяжется с Вами.') |
70 | ->radioList ([0 => 'Не хочу', 1 => 'Хочу стать']); | 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 | echo Html::submitButton('Обновить', ['class' => 'btn btn-primary']); | 90 | echo Html::submitButton('Обновить', ['class' => 'btn btn-primary']); |
72 | $form->end (); | 91 | $form->end (); |
73 | ?> | 92 | ?> |