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

index 0bce8243b8ed9baaecbe1a821ebcacfc96c54a29..1bae11c009e72b8089f290fce26122d3454603eb 100644 (file)
@@ -263,7 +263,6 @@ JS
                         if ($data === null || !isset($data['id'])) {
                             return null;
                         }
-
                         $file = Files::findOne([
                             'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
                             'entity_id' => $data['id']
@@ -292,22 +291,33 @@ JS
                                 'showDrag' => false
                             ],
                             'initialPreview' => function($data) {
+                                if ($data === null || !isset($data['id'])) {
+                                    return [];
+                                }
                                 $file = Files::findOne([
                                     'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
                                     'entity_id' => $data['id']
                                 ]);
-                                return $file ? [$file->url] : [];
+                                return $file ? [Yii::getAlias('@web') . $file->url] : [];
                             },
                             'initialPreviewConfig' => function($data) {
+                                if ($data === null || !isset($data['id'])) {
+                                    return [];
+                                }
                                 $file = Files::findOne([
                                     'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
                                     'entity_id' => $data['id']
                                 ]);
-                                return $file ? [[
+                                if (!$file) {
+                                    return [];
+                                }
+                                $filePath = Yii::getAlias('@webroot') . $file->url;
+                                return [[
                                     'caption' => basename($file->url),
                                     'type' => 'video',
-                                    'size' => @filesize(Yii::getAlias('@webroot') . $file->url)
-                                ]] : [];
+                                    'size' => file_exists($filePath) ? filesize($filePath) : 0,
+                                    'filetype' => mime_content_type($filePath) // (опционально)
+                                ]];
                             },
                             'initialPreviewAsData' => true,
                             'previewSettings' => [