- = $form->field($model, 'fields')->widget(MultipleInput::class, [
-
+ = $form->field($model, 'fields')->widget(MultipleInput::class,[
+ 'cloneButton' => true,
'columns' => [
[
- 'name' => 'field_id',
- 'type' => 'dropDownList',
+ 'name' => 'field_id',
+ 'type' => 'dropDownList',
'title' => 'Поле',
'defaultValue' => null,
'items' => \yii\helpers\ArrayHelper::map(AdditionalFields::find()
@@ -47,21 +48,31 @@ use yii\widgets\ActiveForm;
'options' => ['prompt' => 'Выберите']
],
[
- 'name' => 'value',
+ 'name' => 'value',
'title' => 'Значение',
'enableError' => true,
+ 'type' => InputFile::class,
'options' => [
- 'class' => 'input-priority'
- ]
+ 'language' => 'ru',
+ 'controller' => 'elfinder',
+ // вставляем название контроллера, по умолчанию равен elfinder
+ // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
+ 'name' => 'fields[value]',
+ 'id' => 'fields-value',
+ 'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
+ 'buttonOptions' => ['class' => 'btn btn-primary'],
+ 'value' => $model->fields[0]['value'],
+ 'buttonName' => 'Выбрать файл',
+ ],
],
[
- 'name' => 'order',
+ 'name' => 'order',
'title' => 'Приоритет',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
- ]
+ ],
]
])->label('Дополнительно');
?>
diff --git a/backend/modules/company/views/company/view.php b/backend/modules/company/views/company/view.php
index a96aa83..766cb6a 100755
--- a/backend/modules/company/views/company/view.php
+++ b/backend/modules/company/views/company/view.php
@@ -45,7 +45,11 @@ $this->params['breadcrumbs'][] = $this->title;
'field.name:text:Поле',
[
'attribute' => 'value',
- 'label' => 'Значение'
+ 'format' => 'raw',
+ 'label' => 'Значение',
+ 'value' => function ($model) {
+ return $model->getValue();
+ }
],
],
]); ?>
diff --git a/backend/modules/project/models/Project.php b/backend/modules/project/models/Project.php
index 7613189..32234c5 100755
--- a/backend/modules/project/models/Project.php
+++ b/backend/modules/project/models/Project.php
@@ -7,6 +7,7 @@ use common\models\FieldsValue;
use common\models\FieldsValueNew;
use common\models\ProjectUser;
use yii\helpers\ArrayHelper;
+use Yii;
class Project extends \common\models\Project
{
@@ -31,15 +32,17 @@ class Project extends \common\models\Project
'field_id' => $item->field_id,
'value' => $item->value,
'order' => $item->order,
+ 'type_file' => $item->type_file,
'field_name' => $item->field->name]);
}
$this->fields = $array;
} else {
$this->fields = [
[
- 'field_id' => null,
- 'value' => null,
+ 'field_id' => null,
+ 'value' => null,
'order' => null,
+ 'type_file' => null,
'field_name' => null,
],
];
@@ -70,14 +73,20 @@ class Project extends \common\models\Project
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROJECT]);
foreach ($post['fields'] as $item) {
- $fildsValue = new FieldsValueNew();
- $fildsValue->field_id = $item['field_id'];
- $fildsValue->value = $item['value'];
- $fildsValue->order = $item['order'];
- $fildsValue->item_id = $this->id;
- $fildsValue->item_type = FieldsValueNew::TYPE_PROJECT;
+ $fieldsValue = new FieldsValueNew();
+ $fieldsValue->field_id = $item['field_id'];
+ $fieldsValue->value = $item['value'];
+ $fieldsValue->order = $item['order'];
+ $fieldsValue->item_id = $this->id;
+ $fieldsValue->item_type = FieldsValueNew::TYPE_PROJECT;
- $fildsValue->save();
+ if(is_file(Yii::getAlias('@frontend') . '/web/' . $item['value'])){
+ $fieldsValue->type_file = 'file';
+ }else{
+ $fieldsValue->type_file = 'text';
+ }
+
+ $fieldsValue->save();
}
ProjectUser::deleteAll(['project_id' => $this->id]);
diff --git a/backend/modules/project/views/project/_form.php b/backend/modules/project/views/project/_form.php
index 4ed2289..fd75953 100755
--- a/backend/modules/project/views/project/_form.php
+++ b/backend/modules/project/views/project/_form.php
@@ -4,6 +4,7 @@ use kartik\select2\Select2;
use unclead\multipleinput\MultipleInput;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
+use mihaildev\elfinder\InputFile;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\Project */
@@ -53,7 +54,7 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'fields')->widget(MultipleInput::class, [
-
+ 'cloneButton' => true,
'columns' => [
[
'name' => 'field_id',
@@ -71,8 +72,16 @@ use yii\widgets\ActiveForm;
'name' => 'value',
'title' => 'Значение',
'enableError' => true,
+ 'type' => InputFile::class,
'options' => [
- 'class' => 'input-priority'
+ 'language' => 'ru',
+ 'controller' => 'elfinder',
+ 'name' => 'fields[value]',
+ 'id' => 'fields-value',
+ 'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
+ 'buttonOptions' => ['class' => 'btn btn-primary'],
+ 'value' => $model->fields[0]['value'],
+ 'buttonName' => 'Выбрать файл',
]
],
[
diff --git a/backend/modules/project/views/project/view.php b/backend/modules/project/views/project/view.php
index 8b4676d..896c2d8 100755
--- a/backend/modules/project/views/project/view.php
+++ b/backend/modules/project/views/project/view.php
@@ -47,7 +47,14 @@ $this->params['breadcrumbs'][] = $this->title;
'layout' => "{items}",
'columns' => [
'field.name:text:Поле',
- 'value',
+ [
+ 'attribute' => 'value',
+ 'format' => 'raw',
+ 'label' => 'Значение',
+ 'value' => function ($model) {
+ return $model->getValue();
+ }
+ ],
],
]); ?>
diff --git a/common/models/Balance.php b/common/models/Balance.php
index 3f4465c..cdf2edb 100755
--- a/common/models/Balance.php
+++ b/common/models/Balance.php
@@ -7,6 +7,7 @@ use common\classes\Debug;
use PHPUnit\Framework\MockObject\Matcher\DeferredError;
use yii\db\Query;
use yii\helpers\ArrayHelper;
+use yii;
/**
* This is the model class for table "company".
@@ -42,6 +43,7 @@ class Balance extends \yii\db\ActiveRecord
['field_id' => $item->field_id,
'value' => $item->value,
'order' => $item->order,
+ 'type_file' => $item->type_file,
'field_name' => $item->field->name]);
}
$this->fields = $array;
@@ -51,6 +53,7 @@ class Balance extends \yii\db\ActiveRecord
'field_id' => null,
'value' => null,
'order' => null,
+ 'type_file' => null,
'field_name' => null,
],
];
@@ -82,8 +85,8 @@ class Balance extends \yii\db\ActiveRecord
return ArrayHelper::map(
AdditionalFields::find()
- ->leftJoin('use_field', 'additional_fields.id=use_field.field_id')
- ->where(['use_field.use' => $type])->all(), 'id', 'name'
+ ->leftJoin('use_field', 'additional_fields.id=use_field.field_id')
+ ->where(['use_field.use' => $type])->all(), 'id', 'name'
);
}
@@ -131,14 +134,20 @@ class Balance extends \yii\db\ActiveRecord
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_BALANCE]);
foreach ($post['fields'] as $item) {
- $fildsValue = new FieldsValueNew();
- $fildsValue->field_id = $item['field_id'];
- $fildsValue->value = $item['value'];
- $fildsValue->order = $item['order'];
- $fildsValue->item_id = $this->id;
- $fildsValue->item_type = FieldsValueNew::TYPE_BALANCE;
+ $fieldsValue = new FieldsValueNew();
+ $fieldsValue->field_id = $item['field_id'];
+ $fieldsValue->value = $item['value'];
+ $fieldsValue->order = $item['order'];
+ $fieldsValue->item_id = $this->id;
+ $fieldsValue->item_type = FieldsValueNew::TYPE_BALANCE;
- $fildsValue->save();
+ if(is_file(Yii::getAlias('@frontend') . '/web/' . $item['value'])){
+ $fieldsValue->type_file = 'file';
+ }else{
+ $fieldsValue->type_file = 'text';
+ }
+
+ $fieldsValue->save();
}
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
diff --git a/common/models/Project.php b/common/models/Project.php
index 1f471de..9ec01d3 100755
--- a/common/models/Project.php
+++ b/common/models/Project.php
@@ -52,7 +52,7 @@ class Project extends \yii\db\ActiveRecord
public function rules()
{
return [
- [['name'], 'required'],
+ [['name', 'status'], 'required'],
[['description'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
diff --git a/console/migrations/m200803_135837_add_table_options_to_company_table.php b/console/migrations/m200803_135837_add_table_options_to_company_table.php
new file mode 100644
index 0000000..630bdb3
--- /dev/null
+++ b/console/migrations/m200803_135837_add_table_options_to_company_table.php
@@ -0,0 +1,30 @@
+db->driverName === 'mysql') {
+ $this->execute('ALTER TABLE company DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ if ($this->db->driverName === 'mysql') {
+ $this->execute('ALTER TABLE company DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ENGINE=InnoDB');
+ }
+ }
+}
+