]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Mon, 26 May 2025 07:31:50 +0000 (10:31 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 26 May 2025 07:31:50 +0000 (10:31 +0300)
erp24/views/write_offs_erp/_form.php

index 017ea126cf689fdd69a851a3f0fd8b6c08df7033..d6fcb95df83f410b447ed8ce8a62bc8da3f70b7b 100644 (file)
@@ -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"'