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 @@