tmp commit

This commit is contained in:
iIronside 2022-11-10 16:00:43 +03:00
parent 45b110ac44
commit 1175b9f973
25 changed files with 4032 additions and 95 deletions

View File

@ -78,7 +78,7 @@ return [
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
'baseUrl' => '/secure',
'baseUrl' => '', // TODO /secure
'parsers' => [
'application/json' => 'yii\web\JsonParser',
'text/xml' => 'yii/web/XmlParser',

View File

@ -62,7 +62,7 @@ $this->params['breadcrumbs'][] = 'Резюме';
</div>
<div class="resume-form">
<div>
<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']) ?>

View File

@ -2,6 +2,10 @@
namespace backend\modules\document\controllers;
use backend\modules\card\models\UserCard;
use backend\modules\document\models\DocumentTemplate;
use common\classes\Debug;
use kartik\mpdf\Pdf;
use Yii;
use backend\modules\document\models\Document;
use backend\modules\document\models\DocumentSearch;
@ -66,7 +70,9 @@ class DocumentController extends Controller
{
$model = new Document();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($model->load(Yii::$app->request->post()) && $model->validate()) { // //$model->save(false)
$this::generateDocumentBody($model);
$model->save(false);
return $this->redirect(['view', 'id' => $model->id]);
}
@ -124,4 +130,94 @@ class DocumentController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
public function actionDownload($id): string
{
return $this->render('download', [
'model' => Document::findOne($id)
]);
}
/**
* @param integer $id
* @throws NotFoundHttpException
*/
public function actionUpdateDocumentBody($id)
{
$model = $this->findModel($id);
$model->scenario = $model::SCENARIO_UPDATE_DOCUMENT_BODY;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->updated_at = date('Y-m-d h:i:s');
$model->save();
}
return $this->render('download', [
'model' => $model
]);
}
public function generateDocumentBody(Document $model)
{
$templateModel = DocumentTemplate::findOne($model->template_id);
preg_match_all('/(\${\w+})/', $templateModel->template_body,$out);
$document = $templateModel->template_body;;
foreach ($out[0] as $field) {
if (str_contains($document, $field)) {
if($field == '${contract_number}') {
$fieldValue = 101;
} elseif ($field == '${title}') {
$fieldValue = $model->title;
} elseif ($field == '${company}') {
$fieldValue = $model->company->name;
} elseif ($field == '${manager}') {
$fieldValue = $model->manager->userCard->fio;
} elseif ($field == '${contractor_company}') {
$fieldValue = $model->company->name;
} elseif ($field == '${contractor_manager}') {
$fieldValue = $model->manager->userCard->fio;
}
} else {
$fieldValue = $field;
}
$document = str_replace($field, $fieldValue, $document);
}
$model->body = $document;
}
public function actionDownloadPdf($id)
{
$model = Document::findOne($id);
$pdf = new Pdf(); // or new Pdf();
$mpdf = $pdf->api; // fetches mpdf api
// $mpdf->SetHeader('Resume ' . $model->ti . '||Generated by ITGuild.info At: ' . date("d/m/Y")); // call methods or set any properties
$mpdf->SetFooter('{PAGENO}');
$mpdf->WriteHtml($model->body); // call mpdf write html
echo $mpdf->Output("{$model->title}", 'D'); // call the mpdf api output as needed
}
public function actionDownloadDocx($id)
{
$model = Document::findOne($id);
$pw = new \PhpOffice\PhpWord\PhpWord();
// (B) ADD HTML CONTENT
$section = $pw->addSection();
$resumeText = str_replace(array('<br/>', '<br>', '</br>'), ' ', $model->body);
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $resumeText, false, false);
// (C) SAVE TO DOCX ON SERVER
// $pw->save("convert.docx", "Word2007");
// (D) OR FORCE DOWNLOAD
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"$model->title.docx\"");
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($pw, "Word2007");
$objWriter->save("php://output");
exit();
}
}

View File

@ -17,7 +17,8 @@ class DocumentSearch extends Document
public function rules()
{
return [
[['id', 'company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id'], 'integer'],
[['id', 'company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
[['title', 'body', 'created_at', 'updated_at'], 'safe'],
];
}
@ -62,8 +63,14 @@ class DocumentSearch extends Document
'contractor_company_id' => $this->contractor_company_id,
'manager_id' => $this->manager_id,
'contractor_manager_id' => $this->contractor_manager_id,
'template_id' => $this->template_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'body', $this->body]);
return $dataProvider;
}
}

View File

@ -17,8 +17,8 @@ class DocumentTemplateSearch extends DocumentTemplate
public function rules()
{
return [
[['id'], 'integer'],
[['title', 'template_body'], 'safe'],
[['id', 'status'], 'integer'],
[['title', 'template_body', 'created_at', 'updated_at'], 'safe'],
];
}
@ -59,6 +59,9 @@ class DocumentTemplateSearch extends DocumentTemplate
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'title', $this->title])

View File

@ -1,5 +1,7 @@
<?php
use asmoday74\ckeditor5\EditorClassic;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
@ -8,18 +10,153 @@ use yii\widgets\ActiveForm;
/* @var $form yii\widgets\ActiveForm */
?>
<div class="row">
<div class="col-md-8">
<div class="document-template-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'template_body')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'status')->dropDownList(
StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'template_body')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<!-- composer require --prefer-dist stkevich/yii2-ckeditor5 "*"-->
<!-- --><?//= $form->field($model, 'text')->widget(CKEditor::className(),[
// 'editorOptions' => [ TODO
// 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать
// 'inline' => false, //по умолчанию false
// ],
// ]); ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<!-- ['Акт', $time],-->
<!-- ['Акт сверки', $time],-->
<!-- ['Детализация', $time],-->
<!-- ['Доверенность', $time],-->
<!-- ['Договор', $time],-->
<!-- ['Доп соглашение к договору', $time],-->
<!-- ['Транспортная накладная', $time],-->
<!-- ['Ценовой лист', $time],-->
<div class="col-md-4">
<div class="table-responsive">
<table class="table" id="fieldNameTable">
<thead>
<tr>
<th>Поле</th>
<th>Сигнатура поля</th>
</tr>
</thead>
<tbody>
<tr class="info">
<td class="table-cell"> договора</td>
<td class="table-cell">${contract_number}</td>
</tr>
<tr class="info">
<td class="table-cell">Название</td>
<td class="table-cell">${title}</td>
</tr>
<tr class="info">
<td class="table-cell">Компания</td>
<td class="table-cell">${company}</td>
</tr>
<tr class="info">
<td class="table-cell">Представитель</td>
<td class="table-cell">${manager}</td>
</tr>
<tr class="info">
<td class="table-cell">Компания контрагент</td>
<td class="table-cell">${contractor_company}</td>
</tr>
<tr class="info">
<td class="table-cell">Представитель контрагента</td>
<td class="table-cell">${contractor_manager}</td>
</tr>
<!-- <tr class="info">-->
<!-- <td class="table-cell"></td>-->
<!-- <td class="table-cell"></td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell"> документа</td>-->
<!-- <td class="table-cell">${document_number}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell">от </td>-->
<!-- <td class="table-cell">${from}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell">сумма с НДС</td>-->
<!-- <td class="table-cell">${sum_with_NDS}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell">НДС</td>-->
<!-- <td class="table-cell">${NDS}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell">цена</td>-->
<!-- <td class="table-cell">${price}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell">к договору</td>-->
<!-- <td class="table-cell">${to_the_contract}</td>-->
<!-- </tr>-->
<!-- <tr class="info">-->
<!-- <td class="table-cell"></td>-->
<!-- <td class="table-cell">${number}</td>-->
<!-- </tr>-->
</table>
</div>
<div>
<p>
Нажмите на ячейку чтобы скопировать содержимое
</p>
</div>
</div>
</div>
<script>
const popup = document.createElement('h4')
popup.textContent = 'Скопировано'
popup.style.cssText = `
background: #a6caf0;
position: absolute;
right: 0;
top: 0;
`
document.querySelectorAll('.table-cell').forEach(function (elm) {
elm.style.position = 'relative'
elm.addEventListener('click', function (e) {
e.target.style.backgroundColor = '#76d7c4'
var copyText = e.target.textContent
const el = document.createElement('textarea')
el.value = copyText
document.body.appendChild(el)
el.select()
document.execCommand('copy')
document.body.removeChild(el)
elm.appendChild(popup)
setTimeout(() => {
elm.removeChild(popup)
}, 1000)
})
})
</script>

View File

@ -21,6 +21,12 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'template_body') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>

View File

@ -5,14 +5,12 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentTemplate */
$this->title = 'Create Document Template';
$this->title = 'Создать шаблон документа';
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-template-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,5 +1,6 @@
<?php
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\grid\GridView;
@ -7,16 +8,13 @@ use yii\grid\GridView;
/* @var $searchModel backend\modules\document\models\DocumentTemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Document Templates';
$this->title = 'Шаблоны документов';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-template-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Document Template', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Создать шаблон', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
@ -25,9 +23,19 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'title',
'template_body:ntext',
[
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => function($model){
return StatusHelper::statusLabel($model->status);
}
],
'created_at',
//'updated_at',
// 'template_body:ntext',
['class' => 'yii\grid\ActionColumn'],
],

View File

@ -5,15 +5,13 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentTemplate */
$this->title = 'Update Document Template: ' . $model->title;
$this->title = 'Изменить шаблон: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Document Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-template-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,5 +1,6 @@
<?php
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
@ -13,11 +14,10 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-template-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
<?= 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?',
@ -31,7 +31,24 @@ $this->params['breadcrumbs'][] = $this->title;
'attributes' => [
'id',
'title',
'template_body:ntext',
[
'attribute' => 'status',
'format' => 'raw',
'value' => StatusHelper::statusLabel($model->status),
],
'created_at',
'updated_at',
[
'attribute' => 'template_body',
'format' => 'raw'
],
[
'attribute' => 'Переменные в шаблоне',
'value' => function($model){
preg_match_all('/(\${\w+})/', $model->template_body,$out);
return implode(",", $out[0]);
},
],
],
]) ?>

View File

@ -1,5 +1,9 @@
<?php
use backend\modules\company\models\Company;
use backend\modules\document\models\DocumentTemplate;
use backend\modules\employee\models\Manager;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
@ -12,16 +16,62 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'company_id')->textInput() ?>
<?= $form->field($model, 'company_id')->widget(Select2::class,
[
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'contractor_company_id')->textInput() ?>
<?= $form->field($model, 'manager_id')->widget(Select2::class,
[
'data' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'manager_id')->textInput() ?>
<?= $form->field($model, 'contractor_company_id')->widget(Select2::class,
[
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'contractor_manager_id')->textInput() ?>
<?= $form->field($model, 'contractor_manager_id')->widget(Select2::class,
[
'data' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'template_id')->widget(Select2::class,
[
'data' => DocumentTemplate::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>

View File

@ -25,6 +25,16 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'contractor_manager_id') ?>
<?php // echo $form->field($model, 'template_id') ?>
<?php // echo $form->field($model, 'title') ?>
<?php // echo $form->field($model, 'body') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>

View File

@ -5,14 +5,12 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = 'Create Document';
$this->title = 'Создать документ';
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -0,0 +1,52 @@
<?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\document\models\Document */
$this->title = 'Документ: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Документы', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Загрузить';
?>
<div class="form-group">
<?= Html::a('Редактировать документ', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Просмотр документа', ['view', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</div>
<div class="resume-form">
<?php $form = ActiveForm::begin([
'id' => 'update-resume-text-form',
'action' => Url::to(['document/update-document-body', 'id' => $model->id]),
'options' => ['method' => 'post']])
?>
<?= $form->field($model, 'body')->widget(EditorClassic::className(), [
'clientOptions' => [
'language' => 'ru',
]
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохраниить изменения', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div>
<p>
<?= Html::a('Скачать pdf', ['download-pdf', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Скачать docx', ['download-docx', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
</p>
</div>

View File

@ -1,5 +1,7 @@
<?php
use backend\modules\company\models\Company;
use backend\modules\employee\models\Manager;
use yii\helpers\Html;
use yii\grid\GridView;
@ -7,16 +9,13 @@ use yii\grid\GridView;
/* @var $searchModel backend\modules\document\models\DocumentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Documents';
$this->title = 'Документы';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Document', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Создать документ', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
@ -25,13 +24,47 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'company_id',
'contractor_company_id',
'manager_id',
'contractor_manager_id',
'title',
// 'body:ntext',
[
'attribute' => 'company_id',
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => 'company.name'
],
[
'attribute' => 'contractor_company_id',
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => 'contractorCompany.name'
],
[
'attribute' => 'manager_id',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'value' => 'manager.userCard.fio'
],
[
'attribute' => 'contractor_manager_id',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'value' => 'manager.userCard.fio'
],
//'title',
//'body:ntext',
//'created_at',
//'updated_at',
['class' => 'yii\grid\ActionColumn'],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {download}',
'buttons' => [
'download' => function($url, $model) {
return Html::a(
'<span class="glyphicon glyphicon-download-alt"></span>',
['document/download', 'id' => $model->id]
);
}
]
]
],
]); ?>
</div>

View File

@ -5,15 +5,13 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = 'Update Document: ' . $model->id;
$this->title = 'Изменить документ: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,39 +1,61 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
$this->title = $model->id;
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="document-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Скачать', ['download', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
<?= 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',
'company_id',
'contractor_company_id',
'manager_id',
'contractor_manager_id',
'title',
[
'attribute' => 'company_id',
'value' => ArrayHelper::getValue($model, 'company.name'),
],
[
'attribute' => 'manager_id',
'value' => ArrayHelper::getValue($model, 'manager.userCard.fio'),
],
[
'attribute' => 'contractor_company_id',
'value' => ArrayHelper::getValue($model, 'contractorCompany.name'),
],
[
'attribute' => 'contractor_manager_id',
'value' => ArrayHelper::getValue($model, 'manager.userCard.fio'),
],
[
'attribute' => 'body',
'format' => 'raw',
],
// 'body:ntext',
'created_at',
'updated_at',
],
]) ?>

View File

@ -27,14 +27,15 @@
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields'],
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
['label' => 'Шаблоны резюме', 'icon' => 'file', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template']
['label' => 'Шаблоны резюме', 'icon' => 'file', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template'],
['label' => 'Шаблоны документов', 'icon' => 'file', 'url' => ['/document/document-template'], 'active' => \Yii::$app->controller->id == 'document-template'],
],
'visible' => Yii::$app->user->can('confidential_information')
//'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#',
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', //'active' => \Yii::$app->controller->id == 'user-card',
'items' => $menuItems,
'visible' => Yii::$app->user->can('confidential_information')
//'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Сотрудники', 'icon' => 'users', 'url' => '#',
@ -42,29 +43,19 @@
['label' => 'Менеджеры', 'icon' => 'user-circle-o', 'url' => ['/employee/manager'], 'active' => \Yii::$app->controller->id == 'manager'],
['label' => 'Работники', 'icon' => 'user', 'url' => ['/employee/manager-employee'], 'active' => \Yii::$app->controller->id == 'manager-employee'],
],
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Документы', 'icon' => 'archive', 'url' => '#',
'items' => [
['label' => 'Документы', 'icon' => 'file-text', 'url' => ['/document/document'], 'active' => \Yii::$app->controller->id == 'document'],
['label' => 'Шаблоны', 'icon' => 'file', 'url' => ['/document/template'], 'active' => \Yii::$app->controller->id == 'template'],
['label' => 'Поля документов', 'icon' => 'file-text-o', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field'],
[
'label' => 'Сохранённые значения', 'icon' => 'info-circle', 'url' => '#',
'items' => [
['label' => 'Поля в шаблоне', 'icon' => 'file-text-o', 'url' => ['/document/template-document-field'], 'active' => \Yii::$app->controller->id == 'template-document-field'],
['label' => 'Значения полей', 'icon' => 'bars', 'url' => ['/document/document-field-value'], 'active' => \Yii::$app->controller->id == 'document-field-value'],
]
]
],
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'],
'items' => $projectItems,
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
[
'label' => 'Задачи', 'icon' => 'tasks', 'url' => '#',
@ -72,16 +63,16 @@
['label' => 'Задачи', 'icon' => 'minus', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'],
['label' => 'Исполнители задачи', 'icon' => 'users', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
],
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', ], // 'visible' => Yii::$app->user->can('confidential_information')
[
'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#',
'items' => [
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
],
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')],
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')],
@ -110,7 +101,7 @@
['label' => 'Анкеты пользователей', 'icon' => 'drivers-license', 'url' => ['/questionnaire/user-questionnaire'], 'active' => \Yii::$app->controller->id == 'user-questionnaire'],
['label' => 'Ответы пользователей', 'icon' => 'comments', 'url' => ['/questionnaire/user-response'], 'active' => \Yii::$app->controller->id == 'user-response'],
],
'visible' => Yii::$app->user->can('confidential_information')
// 'visible' => Yii::$app->user->can('confidential_information')
],
['label' => 'Тестовые задания', 'icon' => 'file-text-o', 'url' => ['/test/test-task'], 'active' => \Yii::$app->controller->id == 'options', 'visible' => Yii::$app->user->can('confidential_information')],

View File

@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "document".
@ -12,14 +14,23 @@ use Yii;
* @property int $contractor_company_id
* @property int $manager_id
* @property int $contractor_manager_id
* @property int $template_id
* @property string $title
* @property string $body
* @property string $created_at
* @property string $updated_at
*
* @property Company $company
* @property Company $contractorCompany
* @property Manager $contractorManager
* @property DocumentTemplate $template
* @property Manager $manager
*/
class Document extends \yii\db\ActiveRecord
{
const SCENARIO_GENERATE_DOCUMENT_BODY = 'generate_document_body';
const SCENARIO_UPDATE_DOCUMENT_BODY = 'update_document_body';
/**
* {@inheritdoc}
*/
@ -28,18 +39,37 @@ class Document extends \yii\db\ActiveRecord
return 'document';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['company_id', 'manager_id', 'contractor_manager_id'], 'required'],
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id'], 'integer'],
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'title', 'template_id'], 'required'],
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
[['body'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['company_id' => 'id']],
[['contractor_company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['contractor_company_id' => 'id']],
[['contractor_manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['contractor_manager_id' => 'id']],
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocumentTemplate::className(), 'targetAttribute' => ['template_id' => 'id']],
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
// ['resumeTemplateId', 'required', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
// ['resumeTemplateId', 'integer', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
['body', 'required', 'on' => self::SCENARIO_UPDATE_DOCUMENT_BODY],
];
}
@ -50,13 +80,26 @@ class Document extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
'company_id' => 'Company ID',
'contractor_company_id' => 'Contractor Company ID',
'manager_id' => 'Manager ID',
'contractor_manager_id' => 'Contractor Manager ID',
'company_id' => 'Компания',
'contractor_company_id' => 'Компания контрагент',
'manager_id' => 'Менеджер',
'contractor_manager_id' => 'Менеджер контрагент',
'template_id' => 'Шаблон документа',
'title' => 'Название',
'body' => 'Тело документа',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplate()
{
return $this->hasOne(DocumentTemplate::className(), ['id' => 'template_id']);
}
/**
* @return \yii\db\ActiveQuery
*/

View File

@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "document_template".
@ -10,6 +12,9 @@ use Yii;
* @property int $id
* @property string $title
* @property string $template_body
* @property int $status
* @property string $created_at
* @property string $updated_at
*/
class DocumentTemplate extends \yii\db\ActiveRecord
{
@ -21,13 +26,28 @@ class DocumentTemplate extends \yii\db\ActiveRecord
return 'document_template';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['status', 'title', 'template_body'], 'required'],
[['template_body'], 'string'],
[['status'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
];
}
@ -39,8 +59,11 @@ class DocumentTemplate extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
'title' => 'Title',
'template_body' => 'Template Body',
'title' => 'Название',
'template_body' => 'Тело шаблона',
'status' => 'Статус',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
}

View File

@ -15,7 +15,10 @@ class m221108_135514_create_document_template_table extends Migration
$this->createTable('{{%document_template}}', [
'id' => $this->primaryKey(),
'title' => $this->string(),
'template_body' => $this->text()
'template_body' => $this->text(),
'status' => $this->integer(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
]);
}

View File

@ -15,15 +15,21 @@ class m221108_135939_create_document_table extends Migration
$this->createTable('{{%document}}', [
'id' => $this->primaryKey(),
'company_id' => $this->integer(11)->notNull(),
'contractor_company_id' => $this->integer(11),
'contractor_company_id' => $this->integer(11)->notNull(),
'manager_id' => $this->integer(11)->notNull(),
'contractor_manager_id' => $this->integer(11)->notNull(),
'template_id' => $this->integer(11)->notNull(),
'title' => $this->string(),
'body' => $this->text(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
]);
$this->addForeignKey('company_document', 'document', 'company_id', 'company', 'id');
$this->addForeignKey('contractor_company_document', 'document', 'contractor_company_id', 'company', 'id');
$this->addForeignKey('manager_document', 'document', 'manager_id','manager', 'id');
$this->addForeignKey('contractor_manager_document', 'document', 'contractor_manager_id','manager', 'id');
$this->addForeignKey('document_template_document', 'document', 'template_id','document_template', 'id');
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -15633,3 +15633,29 @@ Stack trace:
2022/10/19 15:27:04 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile?id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2022/10/19 15:27:11 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/profile/get-main-data?user_id=10 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2022/10/19 15:27:14 [error] 3293#3293: *107 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "telegramBotToken" in /var/www/guild/frontend/config/main.php on line 102PHP message: PHP Warning: Undefined array key "telegramBotChatId" in /var/www/guild/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/profile/profile-with-report-permission?id=14 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2022/11/10 15:04:34 [error] 916#916: *388 FastCGI sent in stderr: "PHP message: An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
Stack trace:
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
#1 /var/www/guild/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /var/www/guild/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
#3 [internal function]: yii\base\ErrorHandler->handleException()
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
Stack trace:
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
#1 /var/www/guild/vendor/yiisoft/yii2/base/Application.php(398): yii\web\Response->send()" while reading upstream, client: 127.0.0.1, server: backend.guild.loc, request: "GET /document/document/download-pdf?id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "backend.guild.loc", referrer: "http://backend.guild.loc/document/document/download?id=3"
2022/11/10 15:04:44 [error] 916#916: *388 FastCGI sent in stderr: "PHP message: An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
Stack trace:
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
#1 /var/www/guild/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /var/www/guild/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
#3 [internal function]: yii\base\ErrorHandler->handleException()
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/guild/vendor/mpdf/mpdf/src/Mpdf.php on line 9619. in /var/www/guild/vendor/yiisoft/yii2/web/Response.php:373
Stack trace:
#0 /var/www/guild/vendor/yiisoft/yii2/web/Response.php(346): yii\web\Response->sendHeaders()
#1 /var/www/guild/vendor/yiisoft/yii2/base/Application.php(398): yii\web\Response->send()" while reading upstream, client: 127.0.0.1, server: backend.guild.loc, request: "GET /document/document/download-pdf?id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "backend.guild.loc", referrer: "http://backend.guild.loc/document/document/download?id=3"