]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Tue, 27 May 2025 06:22:15 +0000 (09:22 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 27 May 2025 06:22:15 +0000 (09:22 +0300)
erp24/views/write_offs_erp/_form.php

index 54480c20ed178fe874a0125255d020755575f4e3..6d425eea87461b674bffe9c4c65c9672e00d529f 100644 (file)
@@ -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',