add column document_type to template table

This commit is contained in:
iIronside
2022-01-14 15:39:09 +03:00
parent e09f38f24b
commit c1ff229aa7
8 changed files with 528 additions and 5 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace common\helpers;
use Exception;
use yii\helpers\ArrayHelper;
class TemplateDocumentTypeHelper
{
const STATUS_ACT = 0;
const STATUS_CONTRACT = 1;
public static function getDocumentTypeList() :array
{
return [
self::STATUS_ACT => 'Акт',
self::STATUS_CONTRACT => 'Договор'
];
}
/**
* @throws Exception
*/
public static function getDocumentType($document_type)
{
if (!$document_type) {
return ArrayHelper::getValue(self::getDocumentTypeList(), $document_type);
}
return $document_type;
}
}

View File

@ -16,6 +16,7 @@ use yii\db\Expression;
* @property string $created_at
* @property string $updated_at
* @property string $template_file_name
* @property int $document_type
*
* @property Document[] $documents
* @property TemplateDocumentField[] $templateDocumentFields
@ -54,7 +55,8 @@ class Template extends \yii\db\ActiveRecord
return [
[['created_at', 'updated_at'], 'safe'],
[['title'], 'unique'],
[['template_file_name', 'title'], 'required'],
[['document_type'], 'integer'],
[['template_file_name', 'title', 'document_type'], 'required'],
[['template'], 'required', 'message'=>'Укажите путь к файлу'],
[['template'], 'file', 'maxSize' => '100000'],
[['template'], 'file', 'skipOnEmpty' => true, 'extensions' => 'docx'],
@ -81,6 +83,7 @@ class Template extends \yii\db\ActiveRecord
'created_at' => 'Дата создания',
'updated_at' => 'Дата изменения',
'template_file_name' => 'Файл шаблона',
'document_type' => 'Тип документа',
];
}