From 5ce34fe6050ce2e07f69a6b92607e7c98582cbc2 Mon Sep 17 00:00:00 2001 From: iIronside Date: Thu, 3 Nov 2022 17:46:36 +0300 Subject: [PATCH] add resume --- .../controllers/ResumeTemplateController.php | 127 ++++++++++++++++++ .../card/controllers/UserCardController.php | 123 ++++++++++++----- .../modules/card/models/ResumeTemplate.php | 8 ++ .../card/models/ResumeTemplateSearch.php | 72 ++++++++++ backend/modules/card/models/UserCard.php | 4 +- .../card/views/resume-template/_form.php | 126 +++++++++++++++++ .../card/views/resume-template/_search.php | 37 +++++ .../card/views/resume-template/create.php | 18 +++ .../card/views/resume-template/index.php | 39 ++++++ .../card/views/resume-template/update.php | 19 +++ .../card/views/resume-template/view.php | 47 +++++++ .../modules/card/views/user-card/resume.php | 65 +++++++++ backend/modules/card/views/user-card/view.php | 6 +- .../controllers/ManagerEmployeeController.php | 2 +- backend/views/layouts/left.php | 3 + common/models/ResumeTemplate.php | 108 +++++++++++++++ common/models/UserCard.php | 12 +- ...17_112513_create_resume_template_table.php | 32 +++++ ..._resume_text_column_to_user_card_table.php | 25 ++++ 19 files changed, 830 insertions(+), 43 deletions(-) create mode 100644 backend/modules/card/controllers/ResumeTemplateController.php create mode 100644 backend/modules/card/models/ResumeTemplate.php create mode 100644 backend/modules/card/models/ResumeTemplateSearch.php create mode 100644 backend/modules/card/views/resume-template/_form.php create mode 100644 backend/modules/card/views/resume-template/_search.php create mode 100644 backend/modules/card/views/resume-template/create.php create mode 100644 backend/modules/card/views/resume-template/index.php create mode 100644 backend/modules/card/views/resume-template/update.php create mode 100644 backend/modules/card/views/resume-template/view.php create mode 100644 backend/modules/card/views/user-card/resume.php create mode 100644 common/models/ResumeTemplate.php create mode 100644 console/migrations/m221017_112513_create_resume_template_table.php create mode 100644 console/migrations/m221101_133952_add_resume_text_column_to_user_card_table.php diff --git a/backend/modules/card/controllers/ResumeTemplateController.php b/backend/modules/card/controllers/ResumeTemplateController.php new file mode 100644 index 0000000..d464d6e --- /dev/null +++ b/backend/modules/card/controllers/ResumeTemplateController.php @@ -0,0 +1,127 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all ResumeTemplate models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ResumeTemplateSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single ResumeTemplate model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ResumeTemplate model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ResumeTemplate(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing ResumeTemplate model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing ResumeTemplate model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the ResumeTemplate model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ResumeTemplate the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ResumeTemplate::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index 06d78e2..53c86ae 100755 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -2,14 +2,15 @@ namespace backend\modules\card\controllers; +use backend\modules\card\models\ResumeTemplate; use backend\modules\card\models\UserCard; use backend\modules\card\models\UserCardSearch; +use backend\modules\settings\models\Skill; use common\models\AchievementUserCard; use common\models\CardSkill; use common\models\FieldsValueNew; use common\models\User; use kartik\mpdf\Pdf; -use PhpOffice\PhpWord\PhpWord; use Yii; use yii\data\ActiveDataProvider; use yii\filters\AccessControl; @@ -202,55 +203,109 @@ class UserCardController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } - public function actionDownloadResume($id, $pdf = false) + public function actionResume($id): string { - $model = $this->findModel($id); - - if ($pdf) { - self::getResumePdf($model); - } - self::getResumeDocx($model); + return $this->render('resume', [ + 'model' => UserCard::findOne($id) + ]); } - private function getResumePdf(UserCard $model) + /** + * @param integer $id + * @throws NotFoundHttpException + */ + public function actionResumeTextByTemplate(int $id): string { + $model = $this->findModel($id); + $model->scenario = $model::SCENARIO_GENERATE_RESUME_TEXT; + + if ($model->load(Yii::$app->request->post()) && $model->validate()) { + $this->generateText($model); + $model->save(false); + } + + return $this->render('resume', [ + 'model' => $model + ]); + } + + /** + * @param integer $id + * @throws NotFoundHttpException + */ + public function actionUpdateResumeText($id) + { + $model = $this->findModel($id); + $model->scenario = $model::SCENARIO_UPDATE_RESUME_TEXT; + + if ($model->load(Yii::$app->request->post()) && $model->validate()) { + $model->updated_at = date('Y-m-d h:i:s'); + $model->save(); + } + + return $this->render('resume', [ + 'model' => $model + ]); + } + + private function generateText(UserCard $userCard) { + $resumeTemplate = ResumeTemplate::findOne($userCard->resumeTemplateId); + $resumeText = $resumeTemplate->template_body; + + foreach (ResumeTemplate::$fieldSignatureDbName as $fieldSignature => $fieldDbName ) { + if (str_contains($resumeText, $fieldSignature)) { + if($fieldDbName == 'position_id') { + $fieldValue = $userCard->position->name; + } elseif ($fieldDbName == 'gender') { + $fieldValue = $userCard->getGendersText(); + } elseif ($fieldDbName == 'level') { + $fieldValue = UserCard::getLevelLabel($userCard->level); + } elseif($fieldDbName == 'skills') { + $skills = Skill::find()->select('name') + ->joinWith('cardSkills') + ->where(['card_skill.card_id' => $userCard->id]) + ->column(); + + $fieldValue = implode(', ', $skills); + } else { + $fieldValue = $userCard[$fieldDbName]; + } + $resumeText = str_replace($fieldSignature, $fieldValue, $resumeText); + } + } + $userCard->resume_text = $resumeText; + } + + public function actionDownloadResumePdf($id) + { + $model = UserCard::findOne($id); + $pdf = new Pdf(); // or new Pdf(); $mpdf = $pdf->api; // fetches mpdf api $mpdf->SetHeader('Resume ' . $model->fio . '||Generated At: ' . date("d/m/Y")); // call methods or set any properties $mpdf->SetFooter('{PAGENO}'); - $mpdf->WriteHtml($model->vc_text); // call mpdf write html + $mpdf->WriteHtml($model->resume_text); // call mpdf write html echo $mpdf->Output("Resume - {$model->fio}", 'D'); // call the mpdf api output as needed } - private function getResumeDocx(UserCard $model) + public function actionDownloadResumeDocx($id) { - $phpWord = new PhpWord(); + $model = UserCard::findOne($id); - $sectionStyle = array( - 'orientation' => 'portrait', - 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::pixelToTwip(10), - 'marginLeft' => 600, - 'marginRight' => 600, - 'colsNum' => 1, - 'pageNumberingStart' => 1, - 'borderBottomSize'=>100, - 'borderBottomColor'=>'C0C0C0' - ); - $section = $phpWord->addSection($sectionStyle); - $text = $model->vc_text; - $fontStyle = array('name'=>'Times New Roman', 'size'=>14, 'color'=>'000000', 'bold'=>FALSE, 'italic'=>FALSE); - $parStyle = array('align'=>'both','spaceBefore'=>10); + $pw = new \PhpOffice\PhpWord\PhpWord(); - $section->addText(htmlspecialchars($text), $fontStyle,$parStyle); + // (B) ADD HTML CONTENT + $section = $pw->addSection(); + \PhpOffice\PhpWord\Shared\Html::addHtml($section, $model->resume_text, false, false); - header("Content-Type: application/msword"); - header("Content-Transfer-Encoding: binary"); - header("Content-Disposition: attachment;filename=Resume - {$model->fio}.docx"); - header('Cache-Control: max-age=0'); + // (C) SAVE TO DOCX ON SERVER + // $pw->save("convert.docx", "Word2007"); - $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); - ob_clean(); + // (D) OR FORCE DOWNLOAD + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment;filename=\"Resume-$model->fio.docx\""); + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pw, "Word2007"); $objWriter->save("php://output"); - exit; + exit(); } } diff --git a/backend/modules/card/models/ResumeTemplate.php b/backend/modules/card/models/ResumeTemplate.php new file mode 100644 index 0000000..2f2c996 --- /dev/null +++ b/backend/modules/card/models/ResumeTemplate.php @@ -0,0 +1,8 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + 'status' => $this->status, + ]); + + $query->andFilterWhere(['like', 'title', $this->title]) + ->andFilterWhere(['like', 'template_body', $this->template_body]); + + return $dataProvider; + } +} diff --git a/backend/modules/card/models/UserCard.php b/backend/modules/card/models/UserCard.php index 997a554..9d032f8 100755 --- a/backend/modules/card/models/UserCard.php +++ b/backend/modules/card/models/UserCard.php @@ -123,7 +123,7 @@ class UserCard extends \common\models\UserCard $fieldsValue->save(); } } - if (is_array($post['fields'])) { + if (array_key_exists('fields', $post) && is_array($post['fields'])) { CardSkill::deleteAll(['card_id' => $this->id]); if (is_array($post['skill'])) foreach ($post['skill'] as $item) { @@ -135,7 +135,7 @@ class UserCard extends \common\models\UserCard } } - if(is_array($post['achievements'])){ + if(array_key_exists('achievements', $post) && is_array($post['achievements'])){ AchievementUserCard::deleteAll(['user_card_id' => $this->id]); foreach ($post['achievements'] as $item) { diff --git a/backend/modules/card/views/resume-template/_form.php b/backend/modules/card/views/resume-template/_form.php new file mode 100644 index 0000000..248b749 --- /dev/null +++ b/backend/modules/card/views/resume-template/_form.php @@ -0,0 +1,126 @@ + + +
+
+
+ + + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->dropDownList( + StatusHelper::statusList(), + [ + 'prompt' => 'Выберите' + ] + ) ?> + + field($model, 'template_body')->widget(EditorClassic::className(), [ + 'clientOptions' => [ + 'language' => 'ru', + ] + ]); ?> + +
+ 'btn btn-success']) ?> +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ПолеСигнатура поля
ФИО${fio}
Паспорт${passport}
Электронная почта${email}
Пол${gender}
Резюме${resume}
Зароботная плата${salary}
Позиция${position_id}
Город${city}
Ссылка ВК${link_vk}
Ссылка Телграм${link_telegram}
Резюме текст${vc_text}
Уровень${level}
Резюме текст${vc_text}
Резюме короткий текст${vc_text_short}
Лет опыта${years_of_exp}/td> +
Спецификация${specification}
Навыки${skills}
+
+
+
+ + diff --git a/backend/modules/card/views/resume-template/_search.php b/backend/modules/card/views/resume-template/_search.php new file mode 100644 index 0000000..fa02275 --- /dev/null +++ b/backend/modules/card/views/resume-template/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/modules/card/views/resume-template/create.php b/backend/modules/card/views/resume-template/create.php new file mode 100644 index 0000000..510a59c --- /dev/null +++ b/backend/modules/card/views/resume-template/create.php @@ -0,0 +1,18 @@ +title = 'Создать шаблон резюме'; +$this->params['breadcrumbs'][] = ['label' => 'Resume Templates', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/card/views/resume-template/index.php b/backend/modules/card/views/resume-template/index.php new file mode 100644 index 0000000..d966389 --- /dev/null +++ b/backend/modules/card/views/resume-template/index.php @@ -0,0 +1,39 @@ +title = 'Шаблоны резюме'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'title', + [ + 'attribute' => 'status', + 'format' => 'raw', + 'filter' => StatusHelper::statusList(), + 'value' => function($model){ + return StatusHelper::statusLabel($model->status); + } + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/modules/card/views/resume-template/update.php b/backend/modules/card/views/resume-template/update.php new file mode 100644 index 0000000..0b81f0f --- /dev/null +++ b/backend/modules/card/views/resume-template/update.php @@ -0,0 +1,19 @@ +title = 'Изменить шаблон: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Resume Templates', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/card/views/resume-template/view.php b/backend/modules/card/views/resume-template/view.php new file mode 100644 index 0000000..c946e81 --- /dev/null +++ b/backend/modules/card/views/resume-template/view.php @@ -0,0 +1,47 @@ +title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Resume Templates', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'title', + 'created_at', + 'updated_at', + [ + 'attribute' => 'status', + 'format' => 'raw', + 'filter' => StatusHelper::statusList(), + 'value' => StatusHelper::statusLabel($model->status), + ], + 'template_body:ntext' + ], + ]) ?> + +
diff --git a/backend/modules/card/views/user-card/resume.php b/backend/modules/card/views/user-card/resume.php new file mode 100644 index 0000000..d1fae3a --- /dev/null +++ b/backend/modules/card/views/user-card/resume.php @@ -0,0 +1,65 @@ +title = 'Резюме: ' . $model->fio; +$this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Резюме'; +?> + +
+ 'text-by-template-form', + 'action' => Url::to(['user-card/resume-text-by-template', 'id' => $model->id]), + 'options' => ['method' => 'post']]) + ?> + id); ?> + + field($model, 'resumeTemplateId')->dropDownList( + ResumeTemplate::find()->where(['status' => StatusHelper::STATUS_ACTIVE])->select(['title', 'id'])->indexBy('id')->column(), + ['prompt' => 'Выберите']) + ?> + +
+ 'btn btn-primary']) ?> +
+ + +
+ +
+ + 'update-resume-text-form', + 'action' => Url::to(['user-card/update-resume-text', 'id' => $model->id]), + 'options' => ['method' => 'post']]) + ?> + field($model, 'resume_text')->widget(EditorClassic::className(), [ + 'clientOptions' => [ + 'language' => 'ru', + ] + ]); ?> + +
+ 'btn btn-primary']) ?> +
+ + + +
+ +
+

+ $model->id], ['class' => 'btn btn-success']) ?> + $model->id], ['class' => 'btn btn-success']) ?> +

+
\ No newline at end of file diff --git a/backend/modules/card/views/user-card/view.php b/backend/modules/card/views/user-card/view.php index 0df20ca..4aae97b 100755 --- a/backend/modules/card/views/user-card/view.php +++ b/backend/modules/card/views/user-card/view.php @@ -24,6 +24,7 @@ $this->params['breadcrumbs'][] = $this->title;

'btn btn-primary']) ?> $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], ['class' => 'btn btn-primary']) ?>

params['breadcrumbs'][] = $this->title; ], ]) ?> -

- $model->id, 'pdf' => true], ['class' => 'btn btn-primary']) ?> - $model->id], ['class' => 'btn btn-primary']) ?> -

-

Навыки

name; ?> diff --git a/backend/modules/employee/controllers/ManagerEmployeeController.php b/backend/modules/employee/controllers/ManagerEmployeeController.php index b2a45fe..c53d5ac 100644 --- a/backend/modules/employee/controllers/ManagerEmployeeController.php +++ b/backend/modules/employee/controllers/ManagerEmployeeController.php @@ -65,7 +65,7 @@ class ManagerEmployeeController extends Controller */ public function actionCreate() { - $post = $post = \Yii::$app->request->post('ManagerEmployee'); + $post = \Yii::$app->request->post('ManagerEmployee'); if (!empty($post)) { $user_card_id_arr = ArrayHelper::getValue($post,'user_card_id'); diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index 1467354..bf10536 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -7,6 +7,9 @@ foreach ($userStatuses as $key => $status) { $menuItems[] = ['label' => $status, 'icon' => 'id-card', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]]; } + + $menuItems[] = ['label' => 'Шаблоны резюме', 'icon' => 'id-card', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template']; + $projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT); $projectItems = [['label' => 'Все', 'icon' => 'cubes', 'url' => ['/project/project'], 'active' => \Yii::$app->controller->id == 'project']]; foreach ($projectStatuses as $key => $status) { diff --git a/common/models/ResumeTemplate.php b/common/models/ResumeTemplate.php new file mode 100644 index 0000000..a303f60 --- /dev/null +++ b/common/models/ResumeTemplate.php @@ -0,0 +1,108 @@ + '${fio}', + 'Паспорт' => '${passport}', + 'Электронная почта' => '${email}', + 'Пол' => '${gender}', + 'Резюме' => '${resume}', + 'Зароботная плата' => '${salary}', + 'Позиция' => '${position_id}', + 'Город' => '${city}', + 'Ссылка ВК' => '${link_vk}', + 'Ссылка Телграм' => '${link_telegram}', + 'Резюме текст' => '${vc_text}', + 'Уровень' => '${level}', + 'Резюме короткий текст' => '${vc_text_short}', + 'Лет опыта' => '${years_of_exp}', + 'Спецификация' => '${specification}', + 'Навыки' => '${skills}' + ]; + + public static $fieldSignatureDbName = [ + '${fio}'=> 'fio', + '${passport}'=> 'passport', + '${email}' => 'email', + '${gender}'=> 'gender', + '${resume}'=> 'resume', + '${salary}' => 'salary', + '${position_id}'=> 'position_id', + '${city}'=> 'city', + '${link_vk}' => 'link_vk', + '${link_telegram}' => 'link_telegram', + '${vc_text}' => 'vc_text', + '${level}'=> 'level', + '${vc_text_short}' => 'vc_text_short', + '${years_of_exp}' => 'years_of_exp', + '${specification}'=> 'specification', + '${skills}'=>'skills' + ]; + + /** + * {@inheritdoc} + */ + public static function tableName() + { + return 'resume_template'; + } + + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::class, + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => new Expression('NOW()'), + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [['title', 'status'], 'required'], + [['created_at', 'updated_at'], 'safe'], + [['status'], 'integer'], + [['template_body'], 'string'], + [['title'], 'string', 'max' => 255], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'title' => 'Название', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + 'status' => 'Статус', + 'template_body' => 'Template Body' + ]; + } +} diff --git a/common/models/UserCard.php b/common/models/UserCard.php index 30fadd7..6fb4ac6 100755 --- a/common/models/UserCard.php +++ b/common/models/UserCard.php @@ -38,6 +38,7 @@ use yii\helpers\ArrayHelper; * @property int $level * @property string $test_task_getting_date * @property string $test_task_complete_date + * @property string $resume_text * * @property FieldsValue[] $fieldsValues * @property ProjectUser[] $projectUsers @@ -55,6 +56,11 @@ class UserCard extends \yii\db\ActiveRecord const LEVEL_MIDDLE_PLUS = 3; const LEVEL_SENIOR = 4; + const SCENARIO_GENERATE_RESUME_TEXT = 'generate_resume_text'; + const SCENARIO_UPDATE_RESUME_TEXT = 'update_resume_text'; + + public $resumeTemplateId; + /** * @return string[] */ @@ -111,6 +117,9 @@ class UserCard extends \yii\db\ActiveRecord [['salary'], 'string', 'max' => 100], [['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => Position::class, 'targetAttribute' => ['position_id' => 'id']], [['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']], + ['resumeTemplateId', 'required', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT], + ['resumeTemplateId', 'integer', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT], + ['resume_text', 'required', 'on' => self::SCENARIO_UPDATE_RESUME_TEXT], ]; } @@ -145,6 +154,8 @@ class UserCard extends \yii\db\ActiveRecord 'specification' => 'Спецификация', 'test_task_getting_date' => 'Дата получения тестового', 'test_task_complete_date' => 'Дата выполнения тестового', + 'resumeTemplateId' => 'Шаблон резюме', + 'resume_text' => 'Текст резюме' ]; } @@ -310,5 +321,4 @@ class UserCard extends \yii\db\ActiveRecord return $userCard['id']; } - } diff --git a/console/migrations/m221017_112513_create_resume_template_table.php b/console/migrations/m221017_112513_create_resume_template_table.php new file mode 100644 index 0000000..0114691 --- /dev/null +++ b/console/migrations/m221017_112513_create_resume_template_table.php @@ -0,0 +1,32 @@ +createTable('{{%resume_template}}', [ + 'id' => $this->primaryKey(), + 'title' => $this->string()->notNull(), + 'created_at' => $this->dateTime(), + 'updated_at' => $this->dateTime(), + 'status' => $this->integer(2)->defaultValue(1), + 'template_body' => $this->text(), + ]); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable('{{%resume_template}}'); + } +} diff --git a/console/migrations/m221101_133952_add_resume_text_column_to_user_card_table.php b/console/migrations/m221101_133952_add_resume_text_column_to_user_card_table.php new file mode 100644 index 0000000..97534dc --- /dev/null +++ b/console/migrations/m221101_133952_add_resume_text_column_to_user_card_table.php @@ -0,0 +1,25 @@ +addColumn('user_card', 'resume_text', $this->text()->defaultValue(null)); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('user_card', 'resume_text'); + } +}