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

index 9e6d878522050fda038c0846527475e539452f69..7cf5b5fc001b3d6f6f71ccd43a37df69a8ec68a6 100644 (file)
@@ -256,54 +256,64 @@ JS
 //                    'style' => 'width: 70px;',
                     ]
                 ],
-                [
-                    'name' => 'videoFiles',
-                    'title' => 'Видео: mp4, mov, avi',
-                    'type' => FileInput::className(),
-                    'value' => function ($data) {
-                        if (!$data || !isset($data['id'])) return null;
-
-                        $file = Files::findOne([
-                            'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
-                            'entity_id' => $data['id']
-                        ]);
-
-                        if (!$file) return null;
-
-                        // Prepare initial preview data
-                        $initialPreview = [$file->url];
-                        $initialPreviewConfig = [[
-                            'type' => 'video',
-//                            'filetype' => mime_content_type($file->file_type),
-                            'caption' => basename($file->url),
-                            'url' => Url::to(['delete-video', 'id' => $data['id']])
-                        ]];
-
-                        return [
-                            'caption' => basename($file->url),
-                            'url' => $file->url,
-                            'initialPreview' => $initialPreview,
-                            'initialPreviewConfig' => $initialPreviewConfig
-                        ];
-                    },
-                    'options' => [
-                        'options' => [
-                            'multiple' => false,
-                            'accept' => 'video/*',
-                            'name' => 'video_name'
-                        ],
-                        'pluginOptions' => [
-                            'showPreview' => true,
-                            'showCaption' => true,
-                            'showRemove' => true,
-                            'showUpload' => true,
-                            'previewFileType' => 'video',
-                            'allowedFileTypes' => ['video'],
-                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                            'maxFileSize' => 10240, // 10MB
-                        ],
-                    ],
-                ],
+[
+    'name' => 'videoFiles',
+    'title' => 'Видео: mp4, mov, avi',
+    'type' => FileInput::className(),
+    'value' => function ($data) {
+        if (!$data || !isset($data['id'])) return null;
+
+        $file = Files::findOne([
+            'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+            'entity_id' => $data['id']
+        ]);
+
+        if (!$file) return null;
+
+        // Return just the basic file information
+        return [
+            'caption' => basename($file->url),
+            'url' => $file->url
+        ];
+    },
+    'options' => [
+        'options' => [
+            'multiple' => false,
+            'accept' => 'video/*',
+            'name' => 'video_name'
+        ],
+        'pluginOptions' => [
+            'showPreview' => true,
+            'showCaption' => true,
+            'showRemove' => true,
+            'showUpload' => true,
+            'previewFileType' => 'video',
+            'allowedFileTypes' => ['video'],
+            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+            'maxFileSize' => 10240, // 10MB
+            'initialPreview' => function($data) {
+                if (!$data || !isset($data['id'])) return [];
+                $file = Files::findOne([
+                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                    'entity_id' => $data['id']
+                ]);
+                return $file ? [$file->url] : [];
+            },
+            'initialPreviewConfig' => function($data) {
+                if (!$data || !isset($data['id'])) return [];
+                $file = Files::findOne([
+                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                    'entity_id' => $data['id']
+                ]);
+                return $file ? [[
+                    'type' => 'video',
+                    'caption' => basename($file->url),
+                    'url' => Url::to(['delete-video', 'id' => $data['id']])
+                ]] : [];
+            }
+        ],
+    ],
+],
                 [
                     'name' => 'comment',
                     'type' => 'textInput',