diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php index d708996..d6b2e97 100644 --- a/common/models/Portfolio.php +++ b/common/models/Portfolio.php @@ -142,6 +142,7 @@ { return $this->getSpecializations() ->asArray() + ->indexBy('specialization_id') ->column(); } diff --git a/common/models/Vacancy.php b/common/models/Vacancy.php index 2f899f5..3c65f4a 100644 --- a/common/models/Vacancy.php +++ b/common/models/Vacancy.php @@ -5,6 +5,7 @@ use Yii; use yii\behaviors\BlameableBehavior; use yii\behaviors\TimestampBehavior; + use yii\db\ActiveQuery; use yii\db\Expression; /** @@ -19,6 +20,9 @@ * @property string $user_name * @property string $city * @property string $description + * @property string $phone + * @property string $salary + * @property integer $salary_currency * @property Employment[] $employments * @property VacancyEmployment[] $vacancyEmployments */ @@ -68,7 +72,7 @@ 'string', ], [ - [ 'employmentInput' ], + [ 'employmentInput', 'specializationInput' ], 'safe', ], [ @@ -106,6 +110,9 @@ 'city' => Yii::t('app', 'Город'), 'description' => Yii::t('app', 'Описание'), 'employmentInput' => Yii::t('app', 'Вид занятости'), + 'phone' => Yii::t('app', 'Телефон'), + 'salary' => Yii::t('app', 'Заработная плата'), + 'salary_currency' => Yii::t('app', 'Валюта'), ]; } @@ -140,4 +147,35 @@ return Fields::getData($this->vacancy_id, Vacancy::className(), 'requirements'); } + /** + * @return ActiveQuery + */ + public function getSpecializations() + { + return $this->hasMany(Specialization::className(), [ 'specialization_id' => 'specialization_id' ]) + ->viaTable('vacancy_specialization', [ 'vacancy_id' => 'vacancy_id' ]); + } + + /** + * Return array of Vacancy's specialization IDs + * @return integer[] + */ + public function getSpecializationInput() + { + return $this->getSpecializations() + ->asArray() + ->indexBy('specialization_id') + ->column(); + } + + /** + * Setter which allow to set Vacancy's specializations for further saving to the DB. + * + * @param integer[] $value + */ + public function setSpecializationInput($value) + { + $this->specializationInput = $value; + } + } diff --git a/console/migrations/m160217_092739_currency_table.php b/console/migrations/m160217_092739_currency_table.php index d2f0971..b26d8d0 100644 --- a/console/migrations/m160217_092739_currency_table.php +++ b/console/migrations/m160217_092739_currency_table.php @@ -25,7 +25,7 @@ 'code', 'rate', 'is_default', - 'string', + 'label', ], [ [ 1, diff --git a/console/migrations/m160217_145813_add_fields_february.php b/console/migrations/m160217_145813_add_fields_february.php index 980bfba..2f9e61c 100644 --- a/console/migrations/m160217_145813_add_fields_february.php +++ b/console/migrations/m160217_145813_add_fields_february.php @@ -20,6 +20,7 @@ /* Add phone column to vacancy */ $this->addColumn('{{%vacancy}}', 'phone', $this->string()); + $this->addColumn('{{%vacancy}}', 'salary', $this->string()); } public function down() @@ -28,6 +29,7 @@ $this->dropForeignKey('vacancy_specialization_specialization', '{{%vacancy_specialization}}'); $this->dropColumn('{{%vacancy}}', 'phone'); + $this->dropColumn('{{%vacancy}}', 'salary'); $this->dropTable('{{%vacancy_specialization}}'); } diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 286b20b..6acff0b 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -75,12 +75,10 @@ /** * Page of additional skills, consist: - * * * working with programs; * * education; * * own developments and patents; * * courses and trainings; - * * @return string */ public function actionAddSkills() @@ -94,7 +92,6 @@ /** * Page of blog grid view - * * @return string */ public function actionBlog() @@ -110,7 +107,6 @@ /** * Page of creating one record of blog. - * * @return string|\yii\web\Response Page html / Redirect */ public function actionBlogCreate() @@ -175,11 +171,9 @@ /** * Page of contacts. Consist: - * * * phones; * * social pages; * * sites; - * * @return string page html */ public function actionContacts() @@ -199,7 +193,6 @@ /** * Page of description. Consist of information about User. - * * @return string page html */ public function actionDescription() @@ -219,11 +212,9 @@ /** * Page of seniority. Consist: - * * * current job; * * year of the beginning of designing * * previous jobs - * * @return string page html */ public function actionEmployment() @@ -278,7 +269,6 @@ /** * Page of User's image galleries - * * @return string */ public function actionGallery() @@ -294,7 +284,6 @@ /** * Page of User's videos - * * @return string */ public function actionGalleryVideo() @@ -302,23 +291,20 @@ $user = \Yii::$app->user->identity; - $video = Fields::getData($user->id,Gallery::className(),'youtube'); + $video = Fields::getData($user->id, Gallery::className(), 'youtube'); - - - if(!empty(Yii::$app->request->post('Fields'))) { + if(!empty( Yii::$app->request->post('Fields') )) { Fields::saveFieldVideoData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru'); } return $this->render('gallery-video', [ - 'video' => $video, + 'video' => $video, 'user' => $user, ]); } /** * Page of creating a photo gallery - * * @return string|\yii\web\Response */ public function actionGalleryCreate() @@ -411,7 +397,6 @@ * * * - * * @return string page html */ public function actionGeneral() @@ -458,14 +443,13 @@ /** * Page of User's portfolio - * * @return string */ public function actionPortfolio() { $searchModel = new PortfolioSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - $dataProvider->pagination->pageSize=5; + $dataProvider->pagination->pageSize = 5; return $this->render('portfolio', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, @@ -474,13 +458,15 @@ /** * Page of creating User's portfolio records. - * * @return string|\yii\web\Response */ public function actionPortfolioCreate() { $portfolio = new Portfolio(); - $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); $post = \Yii::$app->request->post(); if(!empty( $post )) { $portfolio->load($post); @@ -489,16 +475,13 @@ $portfolio->save(); $portfolio->unlinkAll('specializations', true); foreach($portfolio->specializationInput as $one_specialization) { - if($one_specialization){ - - $portfolio->link('specializations', Specialization::findOne($one_specialization)); - } + $portfolio->link('specializations', Specialization::findOne($one_specialization)); } return $this->redirect('portfolio'); } } return $this->render('_portfolio_form', [ - 'portfolio' => $portfolio, + 'portfolio' => $portfolio, 'specializations' => $specializations, ]); } @@ -521,7 +504,10 @@ throw new NotFoundHttpException('Запись не найдена'); } - $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); $post = \Yii::$app->request->post(); @@ -531,18 +517,15 @@ if(!$portfolio->hasErrors()) { $portfolio->save(); $portfolio->unlinkAll('specializations', true); - foreach($portfolio->specializationInput as $one_specialization) { - if($one_specialization){ $portfolio->link('specializations', Specialization::findOne($one_specialization)); - } } return $this->redirect('portfolio'); } } return $this->render('_portfolio_form', [ - 'portfolio' => $portfolio, + 'portfolio' => $portfolio, 'specializations' => $specializations, ]); } @@ -570,7 +553,6 @@ /** * Page of User's projects. - * * @return string */ public function actionProjects() @@ -586,14 +568,16 @@ /** * Page of creating User's project. - * * @return string|\yii\web\Response */ public function actionProjectsCreate() { $project = new Project(); - $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); $payment = Payment::find() ->select([ @@ -645,10 +629,10 @@ } } return $this->render('_projects_form', [ - 'project' => $project, + 'project' => $project, 'specializations' => $specializations, - 'payment' => $payment, - 'projects' => $projects, + 'payment' => $payment, + 'projects' => $projects, ]); } @@ -669,7 +653,10 @@ if(!$project instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); } - $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); $payment = Payment::find() ->select([ 'name', @@ -719,10 +706,10 @@ } } return $this->render('_projects_form', [ - 'project' => $project, + 'project' => $project, 'specializations' => $specializations, - 'payment' => $payment, - 'projects' => $projects, + 'payment' => $payment, + 'projects' => $projects, ]); } @@ -738,8 +725,8 @@ { $user = \Yii::$app->user->identity; $project = $user->getProjects() - ->where([ 'project_id' => $id ]) - ->one(); + ->where([ 'project_id' => $id ]) + ->one(); if(!$project instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); } @@ -759,7 +746,6 @@ * * delivery of materials; * * minimal prepayment; * * payment types; - * * @return string */ public function actionService() @@ -769,7 +755,10 @@ if(empty( $user_info )) { $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); } - $specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); $payment = Payment::find() ->select([ 'name', @@ -778,7 +767,7 @@ ->indexBy('payment_id') ->asArray() ->column(); - $currencies = + $currencies = Currency::getCurrencyDropdown(); $post = \Yii::$app->request->post(); if(!empty( $post )) { $user_info->load($post); @@ -797,17 +786,17 @@ } } return $this->render('service', [ - 'user' => $user, - 'user_info' => $user_info, + 'user' => $user, + 'user_info' => $user_info, 'specializations' => $specializations, - 'payment' => $payment, + 'payment' => $payment, + 'currencies' => $currencies, ]); } /** * Page of account setting. Consist of: * * changing password; - * * @return string */ public function actionSetting() @@ -847,7 +836,6 @@ /** * Page of company's team - * * @return string */ public function actionTeam() @@ -863,7 +851,6 @@ /** * Page of creating company's team member - * * @return string|\yii\web\Response */ public function actionTeamCreate() @@ -966,7 +953,6 @@ /** * Page of company's vacancies - * * @return string */ public function actionVacancy() @@ -982,7 +968,6 @@ /** * Page of creating company's vacancies. - * * @return string|\yii\web\Response */ public function actionVacancyCreate() @@ -996,6 +981,11 @@ ->indexBy('employment_id') ->asArray() ->column(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); + $currencies = Currency::getCurrencyDropdown(); $post = \Yii::$app->request->post(); if(!empty( $post )) { $vacancy->load($post); @@ -1007,6 +997,10 @@ foreach($vacancy->employmentInput as $one_employment) { $vacancy->link('employments', Employment::findOne($one_employment)); } + $vacancy->unlinkAll('specializations', true); + foreach($vacancy->specializationInput as $one_specialization) { + $vacancy->link('specializations', Specialization::findOne($one_specialization)); + } return $this->redirect([ 'vacancy-update', 'id' => $vacancy->vacancy_id, @@ -1014,8 +1008,10 @@ } } return $this->render('_vacancy_form', [ - 'vacancy' => $vacancy, - 'employment' => $employment, + 'vacancy' => $vacancy, + 'employment' => $employment, + 'currencies' => $currencies, + 'specializations' => $specializations, ]); } @@ -1031,8 +1027,8 @@ { $user = \Yii::$app->user->identity; $vacancy = $user->getVacancies() - ->where([ 'vacancy_id' => $id ]) - ->one(); + ->where([ 'vacancy_id' => $id ]) + ->one(); if(!$vacancy instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); } @@ -1044,6 +1040,11 @@ ->indexBy('employment_id') ->asArray() ->column(); + $specializations = Specialization::find() + ->where([ 'specialization_pid' => 0 ]) + ->orderBy('specialization_id') + ->all(); + $currencies = Currency::getCurrencyDropdown(); $post = \Yii::$app->request->post(); if(!empty( $post )) { $vacancy->load($post); @@ -1055,6 +1056,10 @@ foreach($vacancy->employmentInput as $one_employment) { $vacancy->link('employments', Employment::findOne($one_employment)); } + $vacancy->unlinkAll('specializations', true); + foreach($vacancy->specializationInput as $one_specialization) { + $vacancy->link('specializations', Specialization::findOne($one_specialization)); + } return $this->redirect([ 'vacancy-update', 'id' => $vacancy->vacancy_id, @@ -1062,8 +1067,10 @@ } } return $this->render('_vacancy_form', [ - 'vacancy' => $vacancy, - 'employment' => $employment, + 'vacancy' => $vacancy, + 'employment' => $employment, + 'currencies' => $currencies, + 'specializations' => $specializations, ]); } @@ -1079,8 +1086,8 @@ { $user = \Yii::$app->user->identity; $vacancy = $user->getVacancies() - ->where([ 'vacancy_id' => $id ]) - ->one(); + ->where([ 'vacancy_id' => $id ]) + ->one(); if(!$vacancy instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); diff --git a/frontend/views/accounts/_portfolio_form.php b/frontend/views/accounts/_portfolio_form.php index f43a15f..1f88185 100644 --- a/frontend/views/accounts/_portfolio_form.php +++ b/frontend/views/accounts/_portfolio_form.php @@ -1,6 +1,7 @@ - -