From a3a98e4a23d0679c54d8052f651fc4ac58d6b7c6 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 27 May 2025 09:22:15 +0300 Subject: [PATCH] ERP-417 --- erp24/views/write_offs_erp/_form.php | 76 +++++++++++++++------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 54480c20..6d425eea 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -253,42 +253,48 @@ JS ] ], [ - 'name' => 'videoFiles', - 'title' => 'Видео: mp4, mov, avi', - 'type' => FileInput::className(), - 'value' => function ($row) { - if (!isset($row['id'])) return null; - - $file = Files::findOne([ + 'name' => 'videoFiles', + 'title' => 'Видео: mp4, mov, avi', + 'type' => FileInput::class, + 'options' => [ + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name', + ], + 'pluginOptions' => [ + 'showPreview' => true, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => false, + 'previewFileType' => 'video', + 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], + 'initialPreview' => isset($model->id) ? [ // или $row['id'], если это в цикле + Files::find() + ->select('url') + ->where([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $model->id // или $row['id'] + ]) + ->scalar() + ] : [], + 'initialPreviewAsData' => true, + 'initialPreviewConfig' => isset($model->id) ? [[ + 'type' => 'video', + 'caption' => basename( + Files::find() + ->select('url') + ->where([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $row['id'] - ]); - - return $file ? $file->url : null; - }, - 'options' => [ - 'options' => [ - 'multiple' => false, - 'accept' => 'video/*', - 'name' => 'video_name', - 'class' => 'file' - ], - 'pluginOptions' => [ - 'showPreview' => false, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - 'browseIcon' => '+', - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', - 'fileActionSettings' => ['showUpload' => false], - 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], - 'maxFileCount' => 1, - 'overwriteInitial' => true, - ], - ] - ], + 'entity_id' => $model->id + ]) + ->scalar() + ), + 'url' => Url::to(['delete-video', 'id' => $model->id]), + ]] : [], + ] + ] +], [ 'name' => 'comment', 'type' => 'textInput', -- 2.39.5