add resume

This commit is contained in:
iIronside 2022-11-03 17:46:36 +03:00
parent 81a3804685
commit 5ce34fe605
19 changed files with 830 additions and 43 deletions

View File

@ -0,0 +1,127 @@
<?php
namespace backend\modules\card\controllers;
use Yii;
use backend\modules\card\models\ResumeTemplate;
use backend\modules\card\models\ResumeTemplateSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ResumeTemplateController implements the CRUD actions for ResumeTemplate model.
*/
class ResumeTemplateController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'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.');
}
}

View File

@ -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();
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace backend\modules\card\models;
class ResumeTemplate extends \common\models\ResumeTemplate
{
}

View File

@ -0,0 +1,72 @@
<?php
namespace backend\modules\card\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\card\models\ResumeTemplate;
/**
* ResumeTemplateSearch represents the model behind the search form of `backend\modules\card\models\ResumeTemplate`.
*/
class ResumeTemplateSearch extends ResumeTemplate
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'status'], 'integer'],
[['title', 'created_at', 'updated_at', 'template_body'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = ResumeTemplate::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $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;
}
}

View File

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

View File

@ -0,0 +1,126 @@
<?php
use asmoday74\ckeditor5\EditorClassic;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\ResumeTemplate */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="row">
<div class="col-md-8">
<div class="resume-template-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(
StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'template_body')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<div class="col-md-4">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Поле</th>
<th>Сигнатура поля</th>
</tr>
</thead>
<tbody>
<tr class="info">
<td>ФИО</td>
<td>${fio}</td>
</tr>
<tr class="info">
<td>Паспорт</td>
<td>${passport}</td>
</tr>
<tr class="info">
<td>Электронная почта</td>
<td>${email}</td>
</tr>
<tr class="info">
<td>Пол</td>
<td>${gender}</td>
</tr>
<tr class="info">
<td>Резюме</td>
<td>${resume}</td>
</tr>
<tr class="info">
<td>Зароботная плата</td>
<td>${salary}</td>
</tr>
<tr class="info">
<td>Позиция</td>
<td>${position_id}</td>
</tr>
<tr class="info">
<td>Город</td>
<td>${city}</td>
</tr>
<tr class="info">
<td>Ссылка ВК</td>
<td>${link_vk}</td>
</tr>
<tr class="info">
<td>Ссылка Телграм</td>
<td>${link_telegram}</td>
</tr>
<tr class="info">
<td>Резюме текст</td>
<td>${vc_text}</td>
</tr>
<tr class="info">
<td>Уровень</td>
<td>${level}</td>
</tr>
<tr class="info">
<td>Резюме текст</td>
<td>${vc_text}</td>
</tr>
<tr class="info">
<td>Резюме короткий текст</td>
<td>${vc_text_short}</td>
</tr>
<tr class="info">
<td>Лет опыта</td>
<td>${years_of_exp}/td>
</tr>
<tr class="info">
<td>Спецификация</td>
<td>${specification}</td>
</tr>
<tr class="info">
<td>Навыки</td>
<td>${skills}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\ResumeTemplateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="resume-template-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<?= $form->field($model, 'status') ?>
<?php // echo $form->field($model, 'template_body') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\ResumeTemplate */
$this->title = 'Создать шаблон резюме';
$this->params['breadcrumbs'][] = ['label' => 'Resume Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="resume-template-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\card\models\ResumeTemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Шаблоны резюме';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="resume-template-index">
<p>
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $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'],
],
]); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\ResumeTemplate */
$this->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';
?>
<div class="resume-template-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use common\helpers\StatusHelper;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\ResumeTemplate */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Resume Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="resume-template-view">
<p>
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'title',
'created_at',
'updated_at',
[
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => StatusHelper::statusLabel($model->status),
],
'template_body:ntext'
],
]) ?>
</div>

View File

@ -0,0 +1,65 @@
<?php
use asmoday74\ckeditor5\EditorClassic;
use backend\modules\card\models\ResumeTemplate;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\UserCard */
$this->title = 'Резюме: ' . $model->fio;
$this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Резюме';
?>
<div class="resume-form">
<?php $form = ActiveForm::begin([
'id' => 'text-by-template-form',
'action' => Url::to(['user-card/resume-text-by-template', 'id' => $model->id]),
'options' => ['method' => 'post']])
?>
<?= Html::hiddenInput('id', $model->id); ?>
<?= $form->field($model, 'resumeTemplateId')->dropDownList(
ResumeTemplate::find()->where(['status' => StatusHelper::STATUS_ACTIVE])->select(['title', 'id'])->indexBy('id')->column(),
['prompt' => 'Выберите'])
?>
<div class="form-group">
<?= Html::submitButton('Сгенерировать резюме по шаблону', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div class="resume-form">
<?php $form = ActiveForm::begin([
'id' => 'update-resume-text-form',
'action' => Url::to(['user-card/update-resume-text', 'id' => $model->id]),
'options' => ['method' => 'post']])
?>
<?= $form->field($model, 'resume_text')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохраниить изменения', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div class="resume-form">
<p>
<?= Html::a('Скачать pdf', ['download-resume-pdf', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Скачать docx', ['download-resume-docx', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
</p>
</div>

View File

@ -24,6 +24,7 @@ $this->params['breadcrumbs'][] = $this->title;
<p>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Резюме', ['user-card/resume', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
@ -101,11 +102,6 @@ $this->params['breadcrumbs'][] = $this->title;
],
]) ?>
<p>
<?= Html::a('Resume pdf', ['download-resume', 'id' => $model->id, 'pdf' => true], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Resume docx', ['download-resume', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</p>
<h2>Навыки</h2>
<?php foreach ($skills as $skill) : ?>
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>

View File

@ -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');

View File

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

View File

@ -0,0 +1,108 @@
<?php
namespace common\models;
use Exception;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "resume_template".
*
* @property int $id
* @property string $title
* @property string $created_at
* @property string $updated_at
* @property int $status
* @property string $template_body
*/
class ResumeTemplate extends \yii\db\ActiveRecord
{
public static $fieldNamesAndSignature = [
'ФИО' => '${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'
];
}
}

View File

@ -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'];
}
}

View File

@ -0,0 +1,32 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%resume_template}}`.
*/
class m221017_112513_create_resume_template_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->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}}');
}
}

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%user_card}}`.
*/
class m221101_133952_add_resume_text_column_to_user_card_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user_card', 'resume_text', $this->text()->defaultValue(null));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user_card', 'resume_text');
}
}