update header from pdf format
This commit is contained in:
parent
4efa463b18
commit
9523ed7475
@ -2,6 +2,7 @@
|
||||
|
||||
namespace backend\modules\card\controllers;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use backend\modules\card\models\ResumeTemplate;
|
||||
use backend\modules\card\models\ResumeTemplateSearch;
|
||||
|
@ -249,7 +249,7 @@ class UserCardController extends Controller
|
||||
}
|
||||
|
||||
private function generateText(UserCard $userCard) {
|
||||
$resumeTemplate = ResumeTemplate::findOne($userCard->resumeTemplateId);
|
||||
$resumeTemplate = ResumeTemplate::findOne($userCard->resume_template_id);
|
||||
$resumeText = $resumeTemplate->template_body;
|
||||
|
||||
foreach (ResumeTemplate::$fieldSignatureDbName as $fieldSignature => $fieldDbName ) {
|
||||
@ -278,24 +278,55 @@ class UserCardController extends Controller
|
||||
|
||||
public function actionDownloadResumePdf($id)
|
||||
{
|
||||
$model = UserCard::findOne($id);
|
||||
$userCard = UserCard::findOne($id);
|
||||
$resumeTemplate = ResumeTemplate::findOne($userCard->resume_template_id);
|
||||
|
||||
$pdf = new Pdf(); // or new Pdf();
|
||||
$mpdf = $pdf->api; // fetches mpdf api
|
||||
$mpdf->SetHeader('Resume ' . $model->fio . '||Generated by ITGuild.info At: ' . date("d/m/Y")); // call methods or set any properties
|
||||
if (empty($resumeTemplate->header_text)) {
|
||||
$headerText = 'Generated by ITGuild.info At: ' . date("d/m/Y");
|
||||
} else {
|
||||
$headerText = $resumeTemplate->header_text;
|
||||
}
|
||||
|
||||
$pdf = new Pdf();
|
||||
$mpdf = $pdf->api;
|
||||
|
||||
if (!pathinfo($resumeTemplate->header_image, PATHINFO_EXTENSION)) {
|
||||
$mpdf->SetHeader($headerText);
|
||||
} else {
|
||||
$imagePath = Yii::getAlias('@frontend') . '/web' . $resumeTemplate->header_image;
|
||||
$mpdf->setAutoTopMargin='stretch';
|
||||
$mpdf->SetHTMLHeader(
|
||||
"<div style='border-bottom: 1px solid #999;'>
|
||||
<p><img src=$imagePath style='width: 100px; height: 40px; margin: 0; vertical-align: middle;'/>$headerText</p>
|
||||
</div>"
|
||||
);
|
||||
}
|
||||
$mpdf->SetFooter('{PAGENO}');
|
||||
$mpdf->WriteHtml($model->resume_text); // call mpdf write html
|
||||
echo $mpdf->Output("Resume - {$model->fio}", 'D'); // call the mpdf api output as needed
|
||||
$mpdf->WriteHTML("<div>$userCard->resume_text</div>");
|
||||
$mpdf->Output("Resume - {$userCard->fio}", 'D'); // call the mpdf api output as needed
|
||||
exit;
|
||||
}
|
||||
|
||||
public function actionDownloadResumeDocx($id)
|
||||
{
|
||||
$model = UserCard::findOne($id);
|
||||
$resumeTemplate = ResumeTemplate::findOne($model->resume_template_id);
|
||||
|
||||
$pw = new \PhpOffice\PhpWord\PhpWord();
|
||||
|
||||
|
||||
// $header = $section->createHeader();
|
||||
// $header->addImage('/home/dev238/projects/aegis/images/Logo_.jpg',['align'=>'right']);
|
||||
|
||||
// (B) ADD HTML CONTENT
|
||||
$section = $pw->addSection();
|
||||
|
||||
|
||||
// $section->addImage( Yii::getAlias('@frontend') . '/media/upload/guild.png', ['width' => '200', 'height' => '200', 'align' => 'center',]);
|
||||
|
||||
|
||||
// $header = $section->addHeader();
|
||||
// $header->addImage('frontend/web/media/upload/guild.png', ['align' => 'left']);
|
||||
$resumeText = str_replace(array('<br/>', '<br>', '</br>'), ' ', $model->resume_text);
|
||||
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $resumeText, false, false);
|
||||
|
||||
|
@ -18,7 +18,7 @@ class ResumeTemplateSearch extends ResumeTemplate
|
||||
{
|
||||
return [
|
||||
[['id', 'status'], 'integer'],
|
||||
[['title', 'created_at', 'updated_at', 'template_body'], 'safe'],
|
||||
[['title', 'created_at', 'updated_at', 'template_body', 'header_text', 'header_image'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -65,8 +65,9 @@ class ResumeTemplateSearch extends ResumeTemplate
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'title', $this->title])
|
||||
->andFilterWhere(['like', 'template_body', $this->template_body]);
|
||||
|
||||
->andFilterWhere(['like', 'template_body', $this->template_body])
|
||||
->andFilterWhere(['like', 'header_text', $this->header_text])
|
||||
->andFilterWhere(['like', 'header_image', $this->header_image]);
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use asmoday74\ckeditor5\EditorClassic;
|
||||
use backend\modules\card\models\ResumeTemplate;
|
||||
use common\helpers\StatusHelper;
|
||||
use mihaildev\elfinder\InputFile;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
@ -31,6 +33,29 @@ use yii\widgets\ActiveForm;
|
||||
]
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'header_text')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<div class="imgUpload form-group">
|
||||
<div class="media__upload_img" style="width: 0">
|
||||
<img src="<?= $model->header_image; ?>" width="100px"/>
|
||||
</div>
|
||||
<?php echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
'controller' => 'elfinder',
|
||||
// вставляем название контроллера, по умолчанию равен elfinder
|
||||
'filter' => 'image',
|
||||
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
|
||||
'name' => 'ResumeTemplate[header_image]',
|
||||
'id' => 'resumeTemplateHeader_img',
|
||||
'template' => '<label>Картинка в верхнем контикуле</label><div class="input-group">{input}<span class="span-btn">{button}</span></div>',
|
||||
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
|
||||
'buttonOptions' => ['class' => 'btn btn-primary'],
|
||||
'value' => $model->header_image,
|
||||
'buttonName' => 'Выбрать изображение',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
@ -49,74 +74,16 @@ use yii\widgets\ActiveForm;
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="info">
|
||||
<td class="table-cell">ФИО</td>
|
||||
<td class="table-cell">${fio}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Паспорт</td>
|
||||
<td class="table-cell">${passport}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Электронная почта</td>
|
||||
<td class="table-cell">${email}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Пол</td>
|
||||
<td class="table-cell">${gender}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Резюме</td>
|
||||
<td class="table-cell">${resume}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Зароботная плата</td>
|
||||
<td class="table-cell">${salary}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Позиция</td>
|
||||
<td class="table-cell">${position_id}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Город</td>
|
||||
<td class="table-cell">${city}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Ссылка ВК</td>
|
||||
<td class="table-cell">${link_vk}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Ссылка Телграм</td>
|
||||
<td class="table-cell">${link_telegram}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Резюме текст</td>
|
||||
<td class="table-cell">${vc_text}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Уровень</td>
|
||||
<td class="table-cell">${level}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Резюме текст</td>
|
||||
<td class="table-cell">${vc_text}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Резюме короткий текст</td>
|
||||
<td class="table-cell">${vc_text_short}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Лет опыта</td>
|
||||
<td class="table-cell">${years_of_exp}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Спецификация</td>
|
||||
<td class="table-cell">${specification}</td>
|
||||
</tr>
|
||||
<tr class="info">
|
||||
<td class="table-cell">Навыки</td>
|
||||
<td class="table-cell">${skills}</td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach (ResumeTemplate::$fieldNamesAndSignature as $fieldNames => $signature) {
|
||||
echo "
|
||||
<tr class='info'>
|
||||
<td class='table-cell'>$fieldNames</td>
|
||||
<td class='table-cell'>$signature</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -27,6 +27,10 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?php // echo $form->field($model, 'template_body') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'header_text') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'header_image') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
|
@ -33,6 +33,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
}
|
||||
],
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
//'template_body:ntext',
|
||||
//'header_text',
|
||||
//'header_image',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -40,7 +40,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'template_body:ntext'
|
||||
'header_text',
|
||||
[
|
||||
'attribute'=>'header_image',
|
||||
'value'=>$model->header_image,
|
||||
'format' => ['image',['width'=>'100','height'=>'100']],
|
||||
],
|
||||
[
|
||||
'attribute' => 'template_body',
|
||||
'format' => 'raw'
|
||||
],
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
@ -29,7 +29,7 @@ $this->params['breadcrumbs'][] = 'Резюме';
|
||||
?>
|
||||
<?= Html::hiddenInput('id', $model->id); ?>
|
||||
|
||||
<?= $form->field($model, 'resumeTemplateId')->dropDownList(
|
||||
<?= $form->field($model, 'resume_template_id')->dropDownList(
|
||||
ResumeTemplate::find()->where(['status' => StatusHelper::STATUS_ACTIVE])->select(['title', 'id'])->indexBy('id')->column(),
|
||||
['prompt' => 'Выберите'])
|
||||
?>
|
||||
|
@ -16,6 +16,8 @@ use yii\helpers\ArrayHelper;
|
||||
* @property string $updated_at
|
||||
* @property int $status
|
||||
* @property string $template_body
|
||||
* @property string $header_text
|
||||
* @property string $header_image
|
||||
*/
|
||||
class ResumeTemplate extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -87,7 +89,7 @@ class ResumeTemplate extends \yii\db\ActiveRecord
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['status'], 'integer'],
|
||||
[['template_body'], 'string'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['title', 'header_text', 'header_image'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
@ -102,7 +104,9 @@ class ResumeTemplate extends \yii\db\ActiveRecord
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'status' => 'Статус',
|
||||
'template_body' => 'Template Body'
|
||||
'template_body' => 'Template Body',
|
||||
'header_text' => 'Текст в верхнем контикуле',
|
||||
'header_image' => 'Картинка в верхнем контикуле',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,11 @@ use yii\helpers\ArrayHelper;
|
||||
* @property string $test_task_getting_date
|
||||
* @property string $test_task_complete_date
|
||||
* @property string $resume_text
|
||||
* @property int $resume_template_id
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property ProjectUser[] $projectUsers
|
||||
* @property ResumeTemplate $resumeTemplate
|
||||
* @property Position $position
|
||||
* @property Status $status0
|
||||
* @property Achievement[] $achievements
|
||||
@ -59,7 +61,7 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
const SCENARIO_GENERATE_RESUME_TEXT = 'generate_resume_text';
|
||||
const SCENARIO_UPDATE_RESUME_TEXT = 'update_resume_text';
|
||||
|
||||
public $resumeTemplateId;
|
||||
// public $resumeTemplateId;
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
@ -117,9 +119,10 @@ 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_template_id', 'required', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
|
||||
['resume_template_id', 'integer', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
|
||||
['resume_text', 'required', 'on' => self::SCENARIO_UPDATE_RESUME_TEXT],
|
||||
// [['resume_template_id'], 'exist', 'skipOnError' => true, 'targetClass' => ResumeTemplate::className(), 'targetAttribute' => ['resume_template_id' => 'id'], 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
|
||||
];
|
||||
}
|
||||
|
||||
@ -154,7 +157,7 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
'specification' => 'Спецификация',
|
||||
'test_task_getting_date' => 'Дата получения тестового',
|
||||
'test_task_complete_date' => 'Дата выполнения тестового',
|
||||
'resumeTemplateId' => 'Шаблон резюме',
|
||||
'resume_template_id' => 'Шаблон резюме',
|
||||
'resume_text' => 'Резюме сгенерированный текст'
|
||||
];
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m221110_133204_add_header__to_resume_template
|
||||
*/
|
||||
class m221110_133204_add_header_to_resume_template extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('resume_template', 'header_text', $this->string());
|
||||
$this->addColumn('resume_template', 'header_image', $this->string());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropColumn('resume_template', 'header_text');
|
||||
$this->dropColumn('resume_template', 'header_image');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m221110_133204_add_header__to_resume_template cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles adding columns to table `{{%user_card}}`.
|
||||
*/
|
||||
class m221111_124753_add_resume_template_id_column_to_user_card_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('user_card','resume_template_id', $this->integer());
|
||||
$this->addForeignKey('resume_template_user_card', 'user_card', 'resume_template_id', 'resume_template', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('resume_template_user_card', 'user_card');
|
||||
$this->dropColumn('user_card', 'resume_template_id');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user