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

index 8b1b269a2a8201b9926ae04fa9a279f40e1d2362..1cd959e7f5b59429312f22f751ee4f265f394427 100644 (file)
@@ -184,26 +184,23 @@ JS
                             'accept' => 'image/*',
                             'name' => 'image_name',
                             'capture' => '',
-                            'class' => 'file',
-                            'required' => true,
+                            'class' => 'file'
                         ],
                         'pluginOptions' => [
-                            'showPreview' => true,
-                            'showCaption' => true, // ✅ Должно быть true
-                            'initialCaption' => '55656',
-                            'initialPreview' => '809',
-//                            'initialPreviewConfig' => function($data) {
-//                                if (!$data || !isset($data['id'])) return [];
-//                                $file = Files::findOne([
-//                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
-//                                    'entity_id' => $data['id']
-//                                ]);
-//                                return $file ? [[
-//                                    'caption' => basename($file->url), // ✅ Обязательно!
-//                                    'type' => 'video',
-//                                    'size' => @filesize(Yii::getAlias('@webroot') . $file->url),
-//                                ]] : [];
-//                            },
+//                        'previewFileType' => ['jpg','png'],
+//                        'allowedFileExtensions'=>['jpg','png'],
+                            'showPreview' => false,
+                            'showCaption' => true,
+                            'showRemove' => true,
+                            'showUpload' => false,
+                            //'uploadClass' => 'hide',
+//                        'initialPreview'=> $initalImages,
+                            'overwriteInitial' => true,
+
+//                        'initialPreviewAsData'=>true,
+                            //initialPreviewAsData: false,
+//                        'bsColCssPrefixes'=>3,
+                            // 'uploadUrl' => Url::to(['/site/image-manager-upload']),
                             'browseIcon' => '+',
                             'cancelIcon' => 'x',
                             'removeIcon' => '-',
@@ -214,9 +211,6 @@ JS
                             'multiple' => true
                         ],
                         'model' => $multipleUploadForm,
-                    ],
-                    'columnOptions' => [
-                        'class' => 'custom_css_class_file_input'
                     ]
                 ],
                 [
@@ -261,52 +255,54 @@ JS
                 [
                     'name' => 'videoFiles',
                     'title' => 'Видео: mp4, mov, avi',
-                    'type' => FileInput::class,
+                    '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']
+                        ]);
+
+                        return $file ? $file->url : null;  // Return just the URL string
+                    },
                     'options' => [
                         'options' => [
                             'multiple' => false,
                             'accept' => 'video/*',
-                            'name' => 'video_name',
+                            'name' => 'video_name'
                         ],
                         'pluginOptions' => [
                             'showPreview' => true,
-                            'showCaption' => false, // 👈 убираем надпись "1 file selected"
+                            'showCaption' => true,
                             'showRemove' => true,
-                            'showUpload' => false,
-                            'browseIcon' => '+', // 👈 как у фото
-                            'cancelIcon' => 'x',
-                            'removeIcon' => '-',
-                            'buttonLabelClass' => 'hidden', // 👈 убираем текст на кнопке
-                            'fileActionSettings' => [
-                                'showUpload' => false
-                            ],
+                            'showUpload' => true,
                             'previewFileType' => 'video',
+                            'allowedFileTypes' => ['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]),
-                            ]] : [],
-                        ]
-                    ]
+                            'maxFileSize' => 10240,
+                            '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',