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

index 3d6d8f5dedd00c59722c006d1877dd39539d1ab4..0c1c2a94d9634dec453c0345043d40eab492bcf8 100644 (file)
@@ -258,58 +258,51 @@ JS
                     'name' => 'videoFiles',
                     'title' => 'Видео: mp4, mov, avi',
                     'type' => FileInput::className(),
-                    'value' => function ($model) {
+                    'options' => function ($row, $index) use ($model) {
+                        $videoUrl = null;
+
+                        if (!empty($model->id)) {
+                            $videoUrl = Files::find()
+                                ->select('url')
+                                ->where([
+                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                                    'entity_id' => $model->id
+                                ])
+                                ->scalar();
+                        }
 
-                        var_dump($model['id']);
-                        die();
-                    },
-                    'options' => [
-                        'options' => [
-                            'multiple' => false,
-                            'accept' => 'video/*',
-                            'name' => 'video_name',
-                            'capture' => '',
-                            'class' => 'videos'
-                        ],
-                        'pluginOptions' => [
-                            'showPreview' => false,
-                            'showCaption' => true,
-                            'showRemove' => true,
-                            'showUpload' => false,
-                            'overwriteInitial' => true,
-                            'browseIcon' => '+',
-                            'cancelIcon' => 'x',
-                            'removeIcon' => '-',
-                            'buttonLabelClass' => 'hidden',
-                            'fileActionSettings' => ['showUpload' => false],
-                            'multiple' => false,
-                            'previewFileType' => 'video',
-                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                            'initialPreview' => isset($model->id) ? [
-                                Files::find()
-                                    ->select('url')
-                                    ->where([
-                                        'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
-                                        'entity_id' => $model->id
-                                    ])
-                                    ->scalar()
-                            ] : [],
-                            'initialPreviewAsData' => true,
-                            'initialPreviewConfig' => isset($model->id) ? [[
-                                'type' => 'video',
-                                'caption' => basename(
-                                    Files::find()
-                                        ->select('url')
-                                        ->where([
-                                            'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
-                                            'entity_id' => $model->id
-                                        ])
-                                        ->scalar()
-                                ),
-                                'url' => Url::to(['delete-video', 'id' => $model->id]),
-                            ]] : [],
-                        ]
-                    ]
+                        return [
+                            'options' => [
+                                'multiple' => false,
+                                'accept' => 'video/*',
+                                'name' => 'video_name',
+                                'capture' => '',
+                                'class' => 'videos'
+                            ],
+                            'pluginOptions' => [
+                                'showPreview' => false,
+                                'showCaption' => true,
+                                'showRemove' => true,
+                                'showUpload' => false,
+                                'overwriteInitial' => true,
+                                'browseIcon' => '+',
+                                'cancelIcon' => 'x',
+                                'removeIcon' => '-',
+                                'buttonLabelClass' => 'hidden',
+                                'fileActionSettings' => ['showUpload' => false],
+                                'multiple' => false,
+                                'previewFileType' => 'video',
+                                'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+                                'initialPreview' => $videoUrl ? [$videoUrl] : [],
+                                'initialPreviewAsData' => true,
+                                'initialPreviewConfig' => $videoUrl ? [[
+                                    'type' => 'video',
+                                    'caption' => basename($videoUrl),
+                                    'url' => Url::to(['delete-video', 'id' => $model->id]),
+                                ]] : [],
+                            ]
+                        ];
+                    }
                 ],
                 [
                     'name' => 'comment',