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

index 435332cc7a7123d8abee9fb495dd24715b5112ab..6b250bd9b7e67829ec31bd7dc0d0418f2048af65 100644 (file)
@@ -257,37 +257,25 @@ JS
                 [
                     'name' => 'videoFiles',
                     'title' => 'Видео: mp4, mov, avi',
-                    'type' => FileInput::className(),
-                    'options' => function ($data) {
+                    'type' => 'raw',
+                    'value' => function ($data, $index) {
                         $videoUrl = null;
 
                         if (!empty($data['id'])) {
-                            $videoUrl = Files::find()
+                            $videoUrl = \common\models\Files::find()
                                 ->select('url')
                                 ->where([
-                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                                    'entity' => \common\models\WriteOffsProductsErp::WRITE_OFFS_VIDEO,
                                     'entity_id' => $data['id']
                                 ])
                                 ->scalar();
                         }
 
-                        $videoPreviewHtml = '';
-                        if ($videoUrl) {
-                            $videoPreviewHtml = '<div class="video-preview" style="margin-left: 20px;">
-                <video controls width="200">
-                    <source src="' . Html::encode($videoUrl) . '" type="video/mp4">
-                    Ваш браузер не поддерживает видео.
-                </video>
-            </div>';
-                        }
-
-                        return [
+                        $input = \kartik\file\FileInput::widget([
+                            'name' => "MultiModel[$index][videoFiles]",
                             'options' => [
-                                'multiple' => false,
                                 'accept' => 'video/*',
-                                'name' => 'video_name',
-                                'capture' => '',
-                                'class' => 'videos'
+                                'class' => 'videos',
                             ],
                             'pluginOptions' => [
                                 'showPreview' => false,
@@ -304,18 +292,26 @@ JS
                                 'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
                                 'initialPreview' => $videoUrl ? [$videoUrl] : [],
                                 'initialPreviewAsData' => true,
-                                'initialCaption' => $videoUrl ? basename($videoUrl) : '',
                                 'initialPreviewConfig' => $videoUrl ? [[
                                     'type' => 'video',
                                     'caption' => basename($videoUrl),
-                                    'url' => Url::to(['delete-video', 'id' => $data['id']]),
+                                    'url' => \yii\helpers\Url::to(['delete-video', 'id' => $data['id']]),
                                 ]] : [],
-                            ],
-                            'groupOptions' => [
-                                'class' => 'd-flex align-items-center',
-                                'template' => '{input}' . $videoPreviewHtml,
-                            ],
-                        ];
+                                'initialCaption' => $videoUrl ? basename($videoUrl) : '',
+                            ]
+                        ]);
+
+                        $videoTag = '';
+                        if ($videoUrl) {
+                            $videoTag = '<div style="margin-left: 20px;">
+                <video controls width="200">
+                    <source src="' . \yii\helpers\Html::encode($videoUrl) . '" type="video/mp4">
+                    Ваш браузер не поддерживает видео.
+                </video>
+            </div>';
+                        }
+
+                        return '<div style="display: flex; align-items: center;">' . $input . $videoTag . '</div>';
                     }
                 ],
                 [