note files data
This commit is contained in:
parent
f7177975a8
commit
5ebdc16a8a
0
backend/modules/notes/Notes.php
Normal file → Executable file
0
backend/modules/notes/Notes.php
Normal file → Executable file
43
backend/modules/notes/models/Note.php
Normal file → Executable file
43
backend/modules/notes/models/Note.php
Normal file → Executable file
@ -2,11 +2,48 @@
|
||||
|
||||
namespace backend\modules\notes\models;
|
||||
|
||||
use Yii;
|
||||
use common\models\FieldsValueNew;
|
||||
|
||||
class Note extends \common\models\Note
|
||||
{
|
||||
|
||||
public $fields;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValueNew::find()
|
||||
->where(
|
||||
[
|
||||
'item_id' => \Yii::$app->request->get('id'),
|
||||
'item_type' => FieldsValueNew::TYPE_NOTE,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if(!empty($fieldValue)){
|
||||
foreach ($fieldValue as $item){
|
||||
array_push($array,
|
||||
['field_id' => $item->field_id,
|
||||
'value' => $item->value,
|
||||
'order' => $item->order,
|
||||
'field_name' => $item->field->name]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
}
|
||||
else{
|
||||
$this->fields = [
|
||||
[
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
'field_name' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Note');
|
||||
@ -21,6 +58,12 @@ class Note extends \common\models\Note
|
||||
$fieldsValue->order = $item['order'];
|
||||
$fieldsValue->value = $item['value'];
|
||||
|
||||
if(is_file(Yii::getAlias('@frontend') . '/web/' . $item['value'])){
|
||||
$fieldsValue->type_file = 'file';
|
||||
}else{
|
||||
$fieldsValue->type_file = 'text';
|
||||
}
|
||||
|
||||
$fieldsValue->save();
|
||||
}
|
||||
|
||||
|
0
backend/modules/notes/models/NoteSearch.php
Normal file → Executable file
0
backend/modules/notes/models/NoteSearch.php
Normal file → Executable file
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\settings\models\AdditionalFields;
|
||||
use mihaildev\elfinder\InputFile;
|
||||
use unclead\multipleinput\MultipleInput;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
@ -36,12 +37,21 @@ use yii\widgets\ActiveForm;
|
||||
'options' => ['prompt' => 'Выберите']
|
||||
],
|
||||
[
|
||||
'name' => 'value',
|
||||
'name' => 'value',
|
||||
'title' => 'Значение',
|
||||
'enableError' => true,
|
||||
'type' => InputFile::className(),
|
||||
'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',
|
||||
|
0
backend/modules/notes/views/notes/index.php
Normal file → Executable file
0
backend/modules/notes/views/notes/index.php
Normal file → Executable file
0
backend/modules/notes/views/notes/update.php
Normal file → Executable file
0
backend/modules/notes/views/notes/update.php
Normal file → Executable file
8
backend/modules/notes/views/notes/view.php
Normal file → Executable file
8
backend/modules/notes/views/notes/view.php
Normal file → Executable file
@ -44,7 +44,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'field.name:text:Поле',
|
||||
[
|
||||
'attribute' => 'value',
|
||||
'label' => 'Значение'
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
if ($model->type_file == 'file') {
|
||||
return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')';
|
||||
}
|
||||
return $model->value;
|
||||
}
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
0
common/models/Note.php
Normal file → Executable file
0
common/models/Note.php
Normal file → Executable file
Loading…
Reference in New Issue
Block a user