Commit 9cc08528cac5f9e54f8a6dbe98f2a6c25b9a01f5

Authored by Yarik
1 parent 37cb2820

test

common/models/Currency.php
... ... @@ -54,4 +54,9 @@ class Currency extends \yii\db\ActiveRecord
54 54 'is_default' => Yii::t('app', 'Is Default'),
55 55 ];
56 56 }
  57 +
  58 + public static function getCurrencyDropdown()
  59 + {
  60 + return self::find()->select(['label', 'currency_id'])->indexBy('currency_id')->orderBy(['is_default' => SORT_DESC, 'currency_id' => SORT_ASC])->asArray()->column();
  61 + }
57 62 }
... ...
common/models/UserInfo.php
... ... @@ -28,6 +28,7 @@
28 28 * @property string $about
29 29 * @property integer $type
30 30 * @property string $geography
  31 + * @property integer $salary_currency
31 32 */
32 33 class UserInfo extends \yii\db\ActiveRecord
33 34 {
... ... @@ -68,6 +69,7 @@
68 69 [
69 70 'is_customer',
70 71 'is_freelancer',
  72 + 'salary_currency',
71 73 ],
72 74 'integer',
73 75 ],
... ... @@ -175,39 +177,40 @@
175 177 public function attributeLabels()
176 178 {
177 179 return [
178   - 'user_id' => Yii::t('app', 'User ID'),
179   - 'view_count' => Yii::t('app', 'Количество просмотров'),
180   - 'busy' => Yii::t('app', 'Статус'),
181   - 'date_visit' => Yii::t('app', 'Дата визита'),
182   - 'experience' => Yii::t('app', 'Опыт работы'),
183   - 'rank' => Yii::t('app', 'Rank'),
184   - 'salary' => Yii::t('app', 'Зарплата'),
185   - 'job' => Yii::t('app', 'Место работы'),
186   - 'location' => Yii::t('app', 'Место расположения'),
187   - 'soft' => Yii::t('app', 'Работа с программами'),
188   - 'user_info_id' => Yii::t('app', 'User Info ID'),
189   - 'guarantee' => Yii::t('app', 'Гарантия качества работ'),
190   - 'contract' => Yii::t('app', 'Работа по договору'),
191   - 'estimate' => Yii::t('app', 'Предоставляете смету'),
192   - 'purchase' => Yii::t('app', 'Делаете сами закупку материалов'),
193   - 'delivery' => Yii::t('app', 'Занимаетесь сами доставкой материалов'),
194   - 'prepayment' => Yii::t('app', 'Минимальная предоплата за работы'),
195   - 'about' => Yii::t('app', 'О себе'),
196   - 'type' => Yii::t('app', 'Is Default'),
197   - 'member' => Yii::t('app', 'Членство в МФП'),
198   - 'alt_location' => 'Город не в списке',
199   - 'country' => Yii::t('app', 'Страна'),
200   - 'city' => Yii::t('app', 'Город'),
201   - 'image' => Yii::t('app', 'Аватар'),
202   - 'poster' => Yii::t('app', 'Подложка'),
203   - 'social_vk' => Yii::t('app', 'Vk.com'),
204   - 'social_fb' => Yii::t('app', 'FaceBook.com'),
205   - 'social_in' => Yii::t('app', 'LinkedIn.com'),
206   - 'social_t' => Yii::t('app', 'Twitter.com'),
207   - 'geography' => Yii::t('app', 'География работ'),
208   - 'geographies' => Yii::t('app', 'География работ'),
209   - 'is_customer' => '',
210   - 'is_freelancer' => '',
  180 + 'user_id' => Yii::t('app', 'User ID'),
  181 + 'view_count' => Yii::t('app', 'Количество просмотров'),
  182 + 'busy' => Yii::t('app', 'Статус'),
  183 + 'date_visit' => Yii::t('app', 'Дата визита'),
  184 + 'experience' => Yii::t('app', 'Опыт работы'),
  185 + 'rank' => Yii::t('app', 'Rank'),
  186 + 'salary' => Yii::t('app', 'Зарплата'),
  187 + 'job' => Yii::t('app', 'Место работы'),
  188 + 'location' => Yii::t('app', 'Место расположения'),
  189 + 'soft' => Yii::t('app', 'Работа с программами'),
  190 + 'user_info_id' => Yii::t('app', 'User Info ID'),
  191 + 'guarantee' => Yii::t('app', 'Гарантия качества работ'),
  192 + 'contract' => Yii::t('app', 'Работа по договору'),
  193 + 'estimate' => Yii::t('app', 'Предоставляете смету'),
  194 + 'purchase' => Yii::t('app', 'Делаете сами закупку материалов'),
  195 + 'delivery' => Yii::t('app', 'Занимаетесь сами доставкой материалов'),
  196 + 'prepayment' => Yii::t('app', 'Минимальная предоплата за работы'),
  197 + 'about' => Yii::t('app', 'О себе'),
  198 + 'type' => Yii::t('app', 'Is Default'),
  199 + 'member' => Yii::t('app', 'Членство в МФП'),
  200 + 'alt_location' => 'Город не в списке',
  201 + 'country' => Yii::t('app', 'Страна'),
  202 + 'city' => Yii::t('app', 'Город'),
  203 + 'image' => Yii::t('app', 'Аватар'),
  204 + 'poster' => Yii::t('app', 'Подложка'),
  205 + 'social_vk' => Yii::t('app', 'Vk.com'),
  206 + 'social_fb' => Yii::t('app', 'FaceBook.com'),
  207 + 'social_in' => Yii::t('app', 'LinkedIn.com'),
  208 + 'social_t' => Yii::t('app', 'Twitter.com'),
  209 + 'geography' => Yii::t('app', 'География работ'),
  210 + 'geographies' => Yii::t('app', 'География работ'),
  211 + 'salary_currency' => Yii::t('app', 'Валюта'),
  212 + 'is_customer' => '',
  213 + 'is_freelancer' => '',
211 214  
212 215 ];
213 216 }
... ...
console/migrations/m160217_092739_currency_table.php
... ... @@ -16,6 +16,7 @@
16 16 'date_update' => $this->timestamp()->defaultExpression('NOW()')
17 17 ->notNull(),
18 18 'is_default' => $this->smallInteger(),
  19 + 'label' => $this->string(),
19 20 ]);
20 21 $this->batchInsert('{{%currency}}', [
21 22 'currency_id',
... ... @@ -24,6 +25,7 @@
24 25 'code',
25 26 'rate',
26 27 'is_default',
  28 + 'string',
27 29 ], [
28 30 [
29 31 1,
... ... @@ -32,6 +34,7 @@
32 34 'USD',
33 35 27.31,
34 36 0,
  37 + '$',
35 38 ],
36 39 [
37 40 2,
... ... @@ -39,7 +42,8 @@
39 42 '€',
40 43 'EUR',
41 44 30.28,
42   - 0
  45 + 0,
  46 + '€',
43 47 ],
44 48 [
45 49 3,
... ... @@ -48,6 +52,7 @@
48 52 'UAH',
49 53 1,
50 54 1,
  55 + 'грн.',
51 56 ],
52 57 [
53 58 4,
... ... @@ -56,6 +61,7 @@
56 61 'RUB',
57 62 0.34,
58 63 0,
  64 + 'руб.',
59 65 ],
60 66 ]);
61 67 }
... ...
frontend/controllers/AccountsController.php
... ... @@ -5,6 +5,7 @@
5 5 use common\models\BlogSearch;
6 6 use common\models\CompanyInfo;
7 7 use common\models\Country;
  8 + use common\models\Currency;
8 9 use common\models\Department;
9 10 use common\models\Employment;
10 11 use common\models\Fields;
... ... @@ -777,6 +778,7 @@
777 778 ->indexBy('payment_id')
778 779 ->asArray()
779 780 ->column();
  781 + $currencies =
780 782 $post = \Yii::$app->request->post();
781 783 if(!empty( $post )) {
782 784 $user_info->load($post);
... ...
frontend/views/accounts/_projects_form.php
... ... @@ -5,6 +5,7 @@
5 5 * @var Payment[] $payment
6 6 * @var string[] $projects
7 7 */
  8 + use common\models\Currency;
8 9 use common\models\Payment;
9 10 use common\models\Project;
10 11 use common\models\Specialization;
... ... @@ -125,8 +126,9 @@
125 126 ->textInput (['class'=> 'custom-input-2','type'=>'number']) ?>
126 127 </div>
127 128 <div class="input-blocks home-input">
128   - <?= $form->field($project, 'budget')
129   - ->textInput (['class'=> 'custom-input-2','type'=>'number']) ?>
  129 + <?=
  130 + $form->field($project, 'budget_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown(), ['class'=> 'custom-input-2']);
  131 + ?>
130 132 </div>
131 133 <div class="input-blocks home-input">
132 134 <?= $form->field($project, 'contractual')
... ...
frontend/views/accounts/service.php
... ... @@ -5,6 +5,7 @@
5 5 * @var string[] $specialization
6 6 * @var string[] $payment
7 7 */
  8 + use common\models\Currency;
8 9 use common\models\Specialization;
9 10 use common\models\User;
10 11 use common\models\UserInfo;
... ... @@ -31,8 +32,11 @@
31 32 ?>
32 33 <div class="input-blocks-wrapper">
33 34 <div class="input-blocks">
  35 + <?=
  36 + $form->field($user_info, 'salary_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown());
  37 + ?>
34 38 <?= $form->field($user_info, 'salary', [
35   - 'template' => "{label}<br /><span class='admn-input-txt'>от</span>{input}<span class='admn-input-txt'><span style='color: red'>ВЫБОР ВАЛЮТЫ!!!!!!!</span>за час</span>\n{hint}\n{error}",
  39 + 'template' => "{label}<br /><span class='admn-input-txt'>от</span>{input}<span class='admn-input-txt'>за час</span>\n{hint}\n{error}",
36 40 'options' => [ 'class' => 'form-inline' ],
37 41 ])
38 42 ->label('Стоимость работ')
... ...