From: marina Date: Mon, 26 May 2025 07:31:50 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=2b1b22a45da9a2931250bcb786d7fac546766b95;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 017ea126..d6fcb95d 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -255,12 +255,44 @@ JS // 'style' => 'width: 70px;', ] ], + [ + 'name' => 'videoFiles', + 'title' => 'Видео: mp4, mov, avi', + 'type' => FileInput::className(), + 'options' => [ + 'pluginOptions' => [ + 'initialPreview' => function ($data) { + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [basename($file->url)] : []; + }, + 'initialPreviewConfig' => function ($data) { + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [ + [ + 'caption' => basename($file->url), + 'type' => 'video', + ] + ] : []; + }, + ], + ], + ], [ 'name' => 'videoFiles', 'title' => 'Видео: mp4, mov, avi', 'type' => FileInput::className(), 'value' => function ($data) { - return basename(Files::findOne(['entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id']])->url ?? ''); + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? basename($file->url) : null; }, 'options' => [ 'options' => [ @@ -283,16 +315,24 @@ JS 'showZoom' => false, 'showDrag' => false ], - 'initialPreview' => [ -// $model->video_name // Показываем текущее название файла - ], - 'initialPreviewConfig' => [ - [ -// 'caption' => $model->video_name, // Подпись под файлом - 'type' => 'video', // Тип файла -// 'size' => filesize($model->getVideoPath()), // Размер файла (если нужно) - ] - ], + 'initialPreview' => function($data) { + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [$file->url] : []; + }, + 'initialPreviewConfig' => function($data) { + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [[ + 'caption' => basename($file->url), + 'type' => 'video', + 'size' => @filesize(Yii::getAlias('@webroot') . $file->url) + ]] : []; + }, 'initialPreviewAsData' => true, 'previewSettings' => [ 'video' => '{width}: "100%", height: "auto"'