custom fields have been added to the documents

This commit is contained in:
iIronside
2022-12-09 16:18:57 +03:00
parent aad1b14473
commit 5b455b59f9
25 changed files with 904 additions and 106 deletions

View File

@ -0,0 +1,40 @@
<?php
use backend\modules\document\models\Document;
use backend\modules\document\models\DocumentField;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
/* @var $form yii\widgets\ActiveForm */
/* @var $fromDocument bool */
?>
<div class="document-field-value-form">
<?php $form = ActiveForm::begin(); ?>
<?php
if (!$fromDocument) {
echo $form->field($model, 'document_field_id')->dropDownList(
ArrayHelper::map(DocumentField::find()->all(), 'id', 'title'),
['prompt' => '...']
);
echo $form->field($model, 'document_id')->dropDownList(
ArrayHelper::map(Document::find()->all(), 'id', 'title'),
['prompt' => '...']
);
}
?>
<?= $form->field($model, 'value')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,36 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $documentFieldValues backend\modules\document\models\DocumentFieldValue[] */
/* @var $form yii\widgets\ActiveForm */
$model = $documentFieldValues[0];
$this->title = 'Заполнение полей документа: ' . $model->document->title;
$this->params['breadcrumbs'][] = ['label' => 'Значения полей документа', 'url' => ['index']];
$this->params['breadcrumbs'][] = $model->document->title;
?>
<div class="document-field-value-form">
<?php $form = ActiveForm::begin(); ?>
<?php foreach ($documentFieldValues as $index => $documentFieldValue) { ?>
<?= $form->field($documentFieldValue, "[$index]value")
->textInput(['maxlength' => true])
->label(ArrayHelper::getValue($documentFieldValue,'documentField.title')
) ?>
<?php } ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValueSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="document-field-value-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'document_field_id') ?>
<?= $form->field($model, 'document_id') ?>
<?= $form->field($model, 'value') ?>
<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,20 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
$this->title = 'Create Document Field Value';
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-value-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,36 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\document\models\DocumentFieldValueSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Document Field Values';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="document-field-value-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Document Field Value', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'document_field_id',
'document_id',
'value',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
/* @var $fromDocument bool */
$this->title = 'Изменить значение поля документа: ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="document-field-value-update">
<?= $this->render('_form', [
'model' => $model,
'fromDocument' => $fromDocument
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\DocumentFieldValue */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Document Field Values', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="document-field-value-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], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'document_field_id',
'document_id',
'value',
],
]) ?>
</div>

View File

@ -1,5 +1,6 @@
<?php
use backend\modules\document\models\DocumentTemplate;
use common\helpers\StatusHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
@ -44,9 +45,8 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'Переменные в шаблоне',
'value' => function($model){
preg_match_all('/(\${\w+})/', $model->template_body,$out);
return implode(",", $out[0]);
'value' => function(DocumentTemplate $model){
return implode(", ", $model->getFields());
},
],
],

View File

@ -53,15 +53,14 @@ use yii\widgets\ActiveForm;
]
); ?>
<?= $form->field($model, 'contractor_company_id')->widget(Select2::class,
<?= $form->field($model, 'contractor_company_id')->dropDownList(
Company::find()->select(['name', 'id'])->indexBy('id')->column(),
[
'data' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['id' => 'contractor-company-id','placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
'id' => 'contractor-company-id',
'prompt' => 'Выберите'
]
); ?>
);
?>
<?= $form->field($model, 'contractor_manager_id')->widget(DepDrop::className(),
[

View File

@ -24,7 +24,6 @@ $this->params['breadcrumbs'][] = 'Загрузить';
<?php $form = ActiveForm::begin([
'id' => 'update-resume-text-form',
'action' => Url::to(['document/update-document-body', 'id' => $model->id]),
'options' => ['method' => 'post']])
?>
@ -35,16 +34,12 @@ $this->params['breadcrumbs'][] = 'Загрузить';
],
]); ?>
<div class="form-group">
<?= Html::submitButton('Сохраниить изменения', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<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']) ?>
<?= Html::a('Скачать pdf', ['download', 'id' => $model->id, 'fileType' => 'docx'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Скачать docx', ['download', 'id' => $model->id, 'fileType' => 'pdf'], ['class' => 'btn btn-success']) ?>
</p>
</div>
</div>

View File

@ -1,6 +1,7 @@
<?php
use backend\modules\company\models\Company;
use backend\modules\company\models\CompanyManager;
use backend\modules\employee\models\Manager;
use yii\helpers\Html;
use yii\grid\GridView;
@ -25,7 +26,6 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\SerialColumn'],
'title',
// 'body:ntext',
[
'attribute' => 'company_id',
'filter' => Company::find()->select(['name', 'id'])->indexBy('id')->column(),
@ -38,24 +38,18 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'manager_id',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'filter' => false,
'value' => 'manager.userCard.fio'
],
[
'attribute' => 'contractor_manager_id',
'filter' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(),
'filter' => false,
'value' => 'manager.userCard.fio'
],
//'title',
//'body:ntext',
//'created_at',
//'updated_at',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {download}',
'template' => '{view} {update} {download} {delete}',
'buttons' => [
'download' => function($url, $model) {
return Html::a(
@ -67,4 +61,5 @@ $this->params['breadcrumbs'][] = $this->title;
]
],
]); ?>
</div>

View File

@ -1,13 +1,13 @@
<?php
use common\classes\Debug;
use common\models\Document;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\document\models\Document */
/* @var $documentFieldValuesDataProvider yii\data\ActiveDataProvider */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Documents', 'url' => ['index']];
@ -49,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'contractor_manager_id',
'value' => ArrayHelper::getValue($model, 'manager.userCard.fio'),
'value' => ArrayHelper::getValue($model, 'contractorManager.userCard.fio'),
],
[
'attribute' => 'body',
@ -61,4 +61,37 @@ $this->params['breadcrumbs'][] = $this->title;
],
]) ?>
<div>
<h2>
<?= 'Поля документа:'?>
</h2>
</div>
<?= GridView::widget([
'dataProvider' => $documentFieldValuesDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'document_field_id',
'value' => 'documentField.title'
],
'attribute' => 'value',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update}',//'{view} {update} {delete}',
'controller' => 'document-field-value',
'buttons' => [
'update' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-pencil"></span>',
['document-field-value/update', 'id' => $model['id'], 'fromDocument' => true]);
},
],
],
],
]); ?>
</div>