From d02fd466ade19613365baef18ffb58add51b8aa8 Mon Sep 17 00:00:00 2001 From: Yarik Date: Wed, 17 Feb 2016 15:59:16 +0200 Subject: [PATCH] test --- common/models/Currency.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/models/Project.php | 11 ++++++++++- common/models/Team.php | 2 +- common/models/UserInfo.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++------------ console/migrations/m160217_131655_currency_connection.php | 26 ++++++++++++++++++++++++++ frontend/controllers/AccountsController.php | 11 ++--------- frontend/views/accounts/_team_form.php | 2 +- frontend/views/accounts/service.php | 22 ++++++++++++++++++++-- frontend/views/layouts/admin.php | 2 +- frontend/views/layouts/company.php | 7 +++++++ frontend/views/layouts/gallery-company.php | 7 +++++++ frontend/views/layouts/gallery.php | 7 +++++++ frontend/views/layouts/main.php | 9 +-------- frontend/views/layouts/performer.php | 7 +++++++ frontend/views/performer/_gallery_list_view.php | 2 +- frontend/views/tender/view.php | 9 ++++++++- 16 files changed, 203 insertions(+), 37 deletions(-) create mode 100644 common/models/Currency.php create mode 100644 console/migrations/m160217_131655_currency_connection.php diff --git a/common/models/Currency.php b/common/models/Currency.php new file mode 100644 index 0000000..72597c7 --- /dev/null +++ b/common/models/Currency.php @@ -0,0 +1,57 @@ + 255], + [['code'], 'string', 'max' => 3], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'currency_id' => Yii::t('app', 'Currency ID'), + 'name' => Yii::t('app', 'Name'), + 'symbol' => Yii::t('app', 'Symbol'), + 'code' => Yii::t('app', 'Code'), + 'rate' => Yii::t('app', 'Rate'), + 'date_update' => Yii::t('app', 'Date Update'), + 'is_default' => Yii::t('app', 'Is Default'), + ]; + } +} diff --git a/common/models/Project.php b/common/models/Project.php index 0dc5cc3..ae5ffbb 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -73,7 +73,6 @@ ], [ [ - 'deadline', 'project_pid', 'payment_variant', 'contractual', @@ -116,6 +115,16 @@ 'default', 'value' => [ ], ], + [ + ['deadline'], + 'integer', + 'min' => 1, + ], + [ + ['deadline'], + 'default', + 'value' => 1, + ], ]; } diff --git a/common/models/Team.php b/common/models/Team.php index 68a03f0..6443805 100644 --- a/common/models/Team.php +++ b/common/models/Team.php @@ -80,7 +80,7 @@ 'experience_from', ], 'integer', - 'max' => 2016, + 'max' => date('Y'), 'min' => 1950, ], [ diff --git a/common/models/UserInfo.php b/common/models/UserInfo.php index f2bcab9..286fbc8 100755 --- a/common/models/UserInfo.php +++ b/common/models/UserInfo.php @@ -3,6 +3,8 @@ namespace common\models; use Yii; + use yii\behaviors\AttributeBehavior; + use yii\db\ActiveRecord; /** * This is the model class for table "user_info". @@ -25,6 +27,7 @@ * @property double $prepayment * @property string $about * @property integer $type + * @property string $geography */ class UserInfo extends \yii\db\ActiveRecord { @@ -69,7 +72,10 @@ 'integer', ], [ - [ 'date_visit' ], + [ + 'date_visit', + 'geographies', + ], 'safe', ], [ @@ -91,6 +97,7 @@ [ 'prepayment' ], 'number', 'min' => 1, + 'max' => 100, ], [ [ 'experience' ], @@ -130,12 +137,22 @@ 'boolean', ], [ - [ 'view_count', 'busy', 'member', 'salary', 'guarantee', 'prepayment' ], + [ + 'view_count', + 'busy', + 'member', + 'salary', + 'guarantee', + 'prepayment', + ], 'default', 'value' => 0, ], [ - ['salary', 'guarantee'], + [ + 'salary', + 'guarantee', + ], 'integer', 'min' => 0, ], @@ -177,19 +194,37 @@ 'prepayment' => Yii::t('app', 'Минимальная предоплата за работы'), 'about' => Yii::t('app', 'О себе'), 'type' => Yii::t('app', 'Is Default'), - 'member' => Yii::t('app', 'Членство в МФП'), + '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'), + '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' => '', ]; } + + public function beforeSave($insert) + { + $this->geography = json_encode($this->geographies, JSON_UNESCAPED_UNICODE); + return parent::beforeSave($insert); + } + + public function getGeographies() + { + return json_decode($this->geography); + } + + public function setGeographies($value) + { + $this->geographies = $value; + } } diff --git a/console/migrations/m160217_131655_currency_connection.php b/console/migrations/m160217_131655_currency_connection.php new file mode 100644 index 0000000..8ed2cb4 --- /dev/null +++ b/console/migrations/m160217_131655_currency_connection.php @@ -0,0 +1,26 @@ +addColumn('{{%user_info}}', 'salary_currency', $this->integer()->defaultValue(3)); + $this->addColumn('{{%vacancy}}', 'salary_currency', $this->integer()->defaultValue(3)); + $this->addColumn('{{%project}}', 'budget_currency', $this->integer()->defaultValue(3)); + $this->addForeignKey('user_info_salary_currency', '{{%user_info}}', 'salary_currency', '{{%currency}}', 'currency_id', 'SET DEFAULT', 'CASCADE'); + $this->addForeignKey('vacancy_salary_currency', '{{%vacancy}}', 'salary_currency', '{{%currency}}', 'currency_id', 'SET DEFAULT', 'CASCADE'); + $this->addForeignKey('project_budget_currency', '{{%project}}', 'budget_currency', '{{%currency}}', 'currency_id', 'SET DEFAULT', 'CASCADE'); + } + + public function down() + { + $this->dropForeignKey('user_info_salary_currency', '{{%user_info}}'); + $this->dropForeignKey('vacancy_salary_currency', '{{%vacancy}}'); + $this->dropForeignKey('project_budget_currency', '{{%project}}'); + $this->dropColumn('{{%user_info}}', 'salary_currency'); + $this->dropColumn('{{%vacancy}}', 'salary_currency'); + $this->dropColumn('{{%project}}', 'budget_currency'); + } +} diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 33b9c39..9b09b44 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -668,14 +668,7 @@ if(!$project instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); } - $specialization = Specialization::find() - ->select([ - 'specialization_name', - 'specialization_id', - ]) - ->indexBy('specialization_id') - ->asArray() - ->column(); + $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); $payment = Payment::find() ->select([ 'name', @@ -726,7 +719,7 @@ } return $this->render('_projects_form', [ 'project' => $project, - 'specialization' => $specialization, + 'specializations' => $specializations, 'payment' => $payment, 'projects' => $projects, ]); diff --git a/frontend/views/accounts/_team_form.php b/frontend/views/accounts/_team_form.php index ddd3b2f..5e53921 100644 --- a/frontend/views/accounts/_team_form.php +++ b/frontend/views/accounts/_team_form.php @@ -72,7 +72,7 @@
field($team, 'experience_from', [ 'template' => "{label},лет
с{input}года \n{hint}\n{error}" ]) - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number'])?> + ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number', 'min' => 1950, 'max' => date('Y')])?>
diff --git a/frontend/views/accounts/service.php b/frontend/views/accounts/service.php index d0e4105..780b322 100755 --- a/frontend/views/accounts/service.php +++ b/frontend/views/accounts/service.php @@ -8,8 +8,10 @@ use common\models\Specialization; use common\models\User; use common\models\UserInfo; + use kartik\select2\Select2; use yii\helpers\ArrayHelper; use yii\helpers\Html; + use yii\web\JsExpression; use yii\widgets\ActiveForm; $this->title = 'Услуги'; @@ -71,8 +73,24 @@
-
- Гоеграфия работ????????????? +
+ field($user_info, 'geographies')->widget(Select2::classname(), [ + 'options' => ['placeholder' => 'Выбор города ...', 'multiple' => true], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'ajax' => [ + 'url' => \yii\helpers\Url::to(['site/city']), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }') + ], + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), + 'templateResult' => new JsExpression('function(city) { return city.text; }'), + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), + ], + ]); + ?>
diff --git a/frontend/views/layouts/admin.php b/frontend/views/layouts/admin.php index a064867..1789928 100755 --- a/frontend/views/layouts/admin.php +++ b/frontend/views/layouts/admin.php @@ -81,7 +81,7 @@ $this->beginContent('@app/views/layouts/main.php'); ], [ 'label' => 'Уведомления о проектах', - 'url' => ['accounts/projects'], + 'url' => ['/projects'], ], [ 'label' => 'Закладки', diff --git a/frontend/views/layouts/company.php b/frontend/views/layouts/company.php index 8e7eaab..88a75f1 100755 --- a/frontend/views/layouts/company.php +++ b/frontend/views/layouts/company.php @@ -162,4 +162,11 @@ $this->beginContent('@app/views/layouts/main.php'); /*====End of blocks created in view====*/ ?>
+ endContent() ?> \ No newline at end of file diff --git a/frontend/views/layouts/gallery-company.php b/frontend/views/layouts/gallery-company.php index 101e257..ad1d471 100755 --- a/frontend/views/layouts/gallery-company.php +++ b/frontend/views/layouts/gallery-company.php @@ -118,4 +118,11 @@ $this->beginContent('@app/views/layouts/main.php');
+ endContent() ?> \ No newline at end of file diff --git a/frontend/views/layouts/gallery.php b/frontend/views/layouts/gallery.php index 2a2e40a..74279a3 100755 --- a/frontend/views/layouts/gallery.php +++ b/frontend/views/layouts/gallery.php @@ -107,5 +107,12 @@ $this->beginContent('@app/views/layouts/main.php'); + endContent() ?> \ No newline at end of file diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 25b524b..9793c3a 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -153,7 +153,7 @@ AppAsset::register($this); ], 'items' => [ [ - 'url' => ['accounts/projects'], + 'url' => ['/projects'], 'template' => '', ], [ @@ -368,13 +368,6 @@ AppAsset::register($this); - endBody() ?> diff --git a/frontend/views/layouts/performer.php b/frontend/views/layouts/performer.php index b6104de..4028d9c 100755 --- a/frontend/views/layouts/performer.php +++ b/frontend/views/layouts/performer.php @@ -140,5 +140,12 @@ $this->beginContent('@app/views/layouts/main.php'); + endContent() ?> \ No newline at end of file diff --git a/frontend/views/performer/_gallery_list_view.php b/frontend/views/performer/_gallery_list_view.php index 105bb2d..0b8cf3d 100644 --- a/frontend/views/performer/_gallery_list_view.php +++ b/frontend/views/performer/_gallery_list_view.php @@ -2,7 +2,7 @@ use yii\helpers\Html; ?> - \ No newline at end of file + + \ No newline at end of file -- libgit2 0.21.4