From 9cc08528cac5f9e54f8a6dbe98f2a6c25b9a01f5 Mon Sep 17 00:00:00 2001 From: Yarik Date: Wed, 17 Feb 2016 17:57:38 +0200 Subject: [PATCH] test --- common/models/Currency.php | 5 +++++ common/models/UserInfo.php | 69 ++++++++++++++++++++++++++++++++++++--------------------------------- console/migrations/m160217_092739_currency_table.php | 8 +++++++- frontend/controllers/AccountsController.php | 2 ++ frontend/views/accounts/_projects_form.php | 6 ++++-- frontend/views/accounts/service.php | 6 +++++- 6 files changed, 59 insertions(+), 37 deletions(-) diff --git a/common/models/Currency.php b/common/models/Currency.php index 72597c7..5dfb757 100644 --- a/common/models/Currency.php +++ b/common/models/Currency.php @@ -54,4 +54,9 @@ class Currency extends \yii\db\ActiveRecord 'is_default' => Yii::t('app', 'Is Default'), ]; } + + public static function getCurrencyDropdown() + { + return self::find()->select(['label', 'currency_id'])->indexBy('currency_id')->orderBy(['is_default' => SORT_DESC, 'currency_id' => SORT_ASC])->asArray()->column(); + } } diff --git a/common/models/UserInfo.php b/common/models/UserInfo.php index 286fbc8..ea31365 100755 --- a/common/models/UserInfo.php +++ b/common/models/UserInfo.php @@ -28,6 +28,7 @@ * @property string $about * @property integer $type * @property string $geography + * @property integer $salary_currency */ class UserInfo extends \yii\db\ActiveRecord { @@ -68,6 +69,7 @@ [ 'is_customer', 'is_freelancer', + 'salary_currency', ], 'integer', ], @@ -175,39 +177,40 @@ public function attributeLabels() { return [ - 'user_id' => Yii::t('app', 'User ID'), - 'view_count' => Yii::t('app', 'Количество просмотров'), - 'busy' => Yii::t('app', 'Статус'), - 'date_visit' => Yii::t('app', 'Дата визита'), - 'experience' => Yii::t('app', 'Опыт работы'), - 'rank' => Yii::t('app', 'Rank'), - 'salary' => Yii::t('app', 'Зарплата'), - 'job' => Yii::t('app', 'Место работы'), - 'location' => Yii::t('app', 'Место расположения'), - 'soft' => Yii::t('app', 'Работа с программами'), - 'user_info_id' => Yii::t('app', 'User Info ID'), - 'guarantee' => Yii::t('app', 'Гарантия качества работ'), - 'contract' => Yii::t('app', 'Работа по договору'), - 'estimate' => Yii::t('app', 'Предоставляете смету'), - 'purchase' => Yii::t('app', 'Делаете сами закупку материалов'), - 'delivery' => Yii::t('app', 'Занимаетесь сами доставкой материалов'), - 'prepayment' => Yii::t('app', 'Минимальная предоплата за работы'), - 'about' => Yii::t('app', 'О себе'), - 'type' => Yii::t('app', 'Is Default'), - 'member' => Yii::t('app', 'Членство в МФП'), - 'alt_location' => 'Город не в списке', - 'country' => Yii::t('app', 'Страна'), - 'city' => Yii::t('app', 'Город'), - 'image' => Yii::t('app', 'Аватар'), - 'poster' => Yii::t('app', 'Подложка'), - 'social_vk' => Yii::t('app', 'Vk.com'), - 'social_fb' => Yii::t('app', 'FaceBook.com'), - 'social_in' => Yii::t('app', 'LinkedIn.com'), - 'social_t' => Yii::t('app', 'Twitter.com'), - 'geography' => Yii::t('app', 'География работ'), - 'geographies' => Yii::t('app', 'География работ'), - 'is_customer' => '', - 'is_freelancer' => '', + 'user_id' => Yii::t('app', 'User ID'), + 'view_count' => Yii::t('app', 'Количество просмотров'), + 'busy' => Yii::t('app', 'Статус'), + 'date_visit' => Yii::t('app', 'Дата визита'), + 'experience' => Yii::t('app', 'Опыт работы'), + 'rank' => Yii::t('app', 'Rank'), + 'salary' => Yii::t('app', 'Зарплата'), + 'job' => Yii::t('app', 'Место работы'), + 'location' => Yii::t('app', 'Место расположения'), + 'soft' => Yii::t('app', 'Работа с программами'), + 'user_info_id' => Yii::t('app', 'User Info ID'), + 'guarantee' => Yii::t('app', 'Гарантия качества работ'), + 'contract' => Yii::t('app', 'Работа по договору'), + 'estimate' => Yii::t('app', 'Предоставляете смету'), + 'purchase' => Yii::t('app', 'Делаете сами закупку материалов'), + 'delivery' => Yii::t('app', 'Занимаетесь сами доставкой материалов'), + 'prepayment' => Yii::t('app', 'Минимальная предоплата за работы'), + 'about' => Yii::t('app', 'О себе'), + 'type' => Yii::t('app', 'Is Default'), + 'member' => Yii::t('app', 'Членство в МФП'), + 'alt_location' => 'Город не в списке', + 'country' => Yii::t('app', 'Страна'), + 'city' => Yii::t('app', 'Город'), + 'image' => Yii::t('app', 'Аватар'), + 'poster' => Yii::t('app', 'Подложка'), + 'social_vk' => Yii::t('app', 'Vk.com'), + 'social_fb' => Yii::t('app', 'FaceBook.com'), + 'social_in' => Yii::t('app', 'LinkedIn.com'), + 'social_t' => Yii::t('app', 'Twitter.com'), + 'geography' => Yii::t('app', 'География работ'), + 'geographies' => Yii::t('app', 'География работ'), + 'salary_currency' => Yii::t('app', 'Валюта'), + 'is_customer' => '', + 'is_freelancer' => '', ]; } diff --git a/console/migrations/m160217_092739_currency_table.php b/console/migrations/m160217_092739_currency_table.php index 40657df..d2f0971 100644 --- a/console/migrations/m160217_092739_currency_table.php +++ b/console/migrations/m160217_092739_currency_table.php @@ -16,6 +16,7 @@ 'date_update' => $this->timestamp()->defaultExpression('NOW()') ->notNull(), 'is_default' => $this->smallInteger(), + 'label' => $this->string(), ]); $this->batchInsert('{{%currency}}', [ 'currency_id', @@ -24,6 +25,7 @@ 'code', 'rate', 'is_default', + 'string', ], [ [ 1, @@ -32,6 +34,7 @@ 'USD', 27.31, 0, + '$', ], [ 2, @@ -39,7 +42,8 @@ '€', 'EUR', 30.28, - 0 + 0, + '€', ], [ 3, @@ -48,6 +52,7 @@ 'UAH', 1, 1, + 'грн.', ], [ 4, @@ -56,6 +61,7 @@ 'RUB', 0.34, 0, + 'руб.', ], ]); } diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 9b09b44..286b20b 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -5,6 +5,7 @@ use common\models\BlogSearch; use common\models\CompanyInfo; use common\models\Country; + use common\models\Currency; use common\models\Department; use common\models\Employment; use common\models\Fields; @@ -777,6 +778,7 @@ ->indexBy('payment_id') ->asArray() ->column(); + $currencies = $post = \Yii::$app->request->post(); if(!empty( $post )) { $user_info->load($post); diff --git a/frontend/views/accounts/_projects_form.php b/frontend/views/accounts/_projects_form.php index 835c9fe..d2f3bdd 100644 --- a/frontend/views/accounts/_projects_form.php +++ b/frontend/views/accounts/_projects_form.php @@ -5,6 +5,7 @@ * @var Payment[] $payment * @var string[] $projects */ + use common\models\Currency; use common\models\Payment; use common\models\Project; use common\models\Specialization; @@ -125,8 +126,9 @@ ->textInput (['class'=> 'custom-input-2','type'=>'number']) ?>
- field($project, 'budget') - ->textInput (['class'=> 'custom-input-2','type'=>'number']) ?> + field($project, 'budget_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown(), ['class'=> 'custom-input-2']); + ?>
field($project, 'contractual') diff --git a/frontend/views/accounts/service.php b/frontend/views/accounts/service.php index 780b322..796486f 100755 --- a/frontend/views/accounts/service.php +++ b/frontend/views/accounts/service.php @@ -5,6 +5,7 @@ * @var string[] $specialization * @var string[] $payment */ + use common\models\Currency; use common\models\Specialization; use common\models\User; use common\models\UserInfo; @@ -31,8 +32,11 @@ ?>
+ field($user_info, 'salary_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown()); + ?> field($user_info, 'salary', [ - 'template' => "{label}
от{input}ВЫБОР ВАЛЮТЫ!!!!!!!за час\n{hint}\n{error}", + 'template' => "{label}
от{input}за час\n{hint}\n{error}", 'options' => [ 'class' => 'form-inline' ], ]) ->label('Стоимость работ') -- libgit2 0.21.4