From 1b56164e1040f0cf486f6f7c3aa24a3173ea0ec3 Mon Sep 17 00:00:00 2001 From: Yarik Date: Thu, 18 Feb 2016 11:51:16 +0200 Subject: [PATCH] test --- common/models/Portfolio.php | 1 + common/models/Vacancy.php | 40 +++++++++++++++++++++++++++++++++++++++- console/migrations/m160217_092739_currency_table.php | 2 +- console/migrations/m160217_145813_add_fields_february.php | 2 ++ frontend/controllers/AccountsController.php | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------- frontend/views/accounts/_portfolio_form.php | 65 +++++++++++++++++++++++++++++++++++++---------------------------- frontend/views/accounts/_vacancy_form.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- frontend/views/accounts/employment.php | 3 +-- frontend/views/accounts/service.php | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------- 9 files changed, 330 insertions(+), 215 deletions(-) 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 @@ - -
- -
+
+ +
diff --git a/frontend/views/accounts/_vacancy_form.php b/frontend/views/accounts/_vacancy_form.php index e9d17c0..8c69b4b 100644 --- a/frontend/views/accounts/_vacancy_form.php +++ b/frontend/views/accounts/_vacancy_form.php @@ -2,11 +2,13 @@ /** * @var Vacancy $vacancy * @var Employment[] $employment + * @var string[] $currencies + * @var Specialization[] $specializations */ use common\models\Employment; + use common\models\Specialization; use common\models\Vacancy; use common\widgets\FieldEditor; - use common\widgets\ImageUploader; use kartik\select2\Select2; use mihaildev\ckeditor\CKEditor; use yii\helpers\Html; @@ -29,8 +31,6 @@ - -
field($vacancy, 'link') @@ -48,8 +48,8 @@
- сюда нужен инпут телефон - + field($vacancy, 'phone') + ->textInput (['class'=> 'custom-input-2']); ?> Ваш
@@ -77,6 +77,52 @@
+
+
+ field($vacancy, 'salary') + ->textInput (['class'=> 'custom-input-2']); ?> + field($vacancy, 'salary_currency') + ->label(false)->dropDownList($currencies); ?> +
+
+ +
+ +
+
field($vacancy, 'employmentInput') diff --git a/frontend/views/accounts/employment.php b/frontend/views/accounts/employment.php index ec935b8..eab56c6 100755 --- a/frontend/views/accounts/employment.php +++ b/frontend/views/accounts/employment.php @@ -109,7 +109,7 @@
- field ($current, '[0]date_start') + field ($job_model, '['. ($index + 1) .']date_start') ->label ('Дата начала работы') ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); ?> @@ -179,7 +179,6 @@ var lastindex; if(result != null) { lastindex = result[1]; - console.log('111111111') } else { lastindex = 1; $('.prev_job_container').removeClass('none-job-inputs') diff --git a/frontend/views/accounts/service.php b/frontend/views/accounts/service.php index 796486f..c30888d 100755 --- a/frontend/views/accounts/service.php +++ b/frontend/views/accounts/service.php @@ -1,9 +1,10 @@
- field($user_info, 'salary_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown()); - ?> + field($user_info, 'salary_currency') + ->label(false) + ->dropDownList($currencies); ?> field($user_info, 'salary', [ 'template' => "{label}
от{input}за час\n{hint}\n{error}", 'options' => [ 'class' => 'form-inline' ], ]) - ->label('Стоимость работ') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + ->label('Стоимость работ') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
- 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; }'), - ], - ]); - ?> + 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; }'), + ], + ]); ?>
@@ -103,92 +113,94 @@ 'template' => "{label}
{input}лет\n{hint}\n{error}", 'options' => [ 'class' => 'form-inline' ], ]) - ->label('Гарантия качества работ') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date custom-input-2-margin-r','type'=>'number']) ?> + ->label('Гарантия качества работ') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date custom-input-2-margin-r', + 'type' => 'number', + ]) ?>
field($user_info, 'contract', [ 'options' => [ 'class' => 'form-inline' ] ]) - ->label('Работа по договору') - ->radioList([ - 1 => 'Да', - 0 => 'Нет', - ], - [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ]) ?> + ->label('Работа по договору') + ->radioList([ + 1 => 'Да', + 0 => 'Нет', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]) ?>
field($user_info, 'estimate', [ 'options' => [ 'class' => 'form-inline' ] ]) - ->label('Предоставляете смету') - ->radioList([ - 1 => 'Да', - 0 => 'Нет', - ], [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ]) ?> + ->label('Предоставляете смету') + ->radioList([ + 1 => 'Да', + 0 => 'Нет', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]) ?>
field($user_info, 'purchase', [ 'options' => [ 'class' => 'form-inline' ] ]) - ->label('Делаете сами закупку материалов') - ->radioList([ - 1 => 'Да', - 0 => 'Нет', - ], [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ]) ?> + ->label('Делаете сами закупку материалов') + ->radioList([ + 1 => 'Да', + 0 => 'Нет', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]) ?>
field($user_info, 'delivery', [ 'options' => [ 'class' => 'form-inline' ] ]) - ->label('Занимаетесь сами доставкой материалов') - ->radioList([ - 1 => 'Да', - 0 => 'Нет', - ], [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ]) ?> + ->label('Занимаетесь сами доставкой материалов') + ->radioList([ + 1 => 'Да', + 0 => 'Нет', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]) ?>
@@ -198,28 +210,29 @@ 'template' => "{label}
{input}%\n{hint}\n{error}", 'options' => [ 'class' => 'form-inline' ], ]) - ->label('Минимальная предоплата за работы') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date custom-input-2-margin-r','type'=>'number'])?> + ->label('Минимальная предоплата за работы') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date custom-input-2-margin-r', + 'type' => 'number', + ]) ?>
field($user, 'paymentInput', [ 'template' => "{label}\n{input}\n{error}" ]) - ->label('Способы оплаты') - ->checkboxList($payment, - [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ] - ) ?> + ->label('Способы оплаты') + ->checkboxList($payment, [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]) ?>
-- libgit2 0.21.4