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

index 1cd959e7f5b59429312f22f751ee4f265f394427..85f9ea48c301ec2626e698ab49fdfeecb76694de 100644 (file)
@@ -174,45 +174,6 @@ JS
                     ],
 //                'items' => [0,1],
                 ],
-                [
-                    'name' => 'imageFiles',
-                    'title' => 'Фотографии: jpg и png',
-                    'type' => FileInput::className(),
-                    'options' => [
-                        'options' => [
-                            'multiple' => true,
-                            'accept' => 'image/*',
-                            'name' => 'image_name',
-                            'capture' => '',
-                            'class' => 'file'
-                        ],
-                        'pluginOptions' => [
-//                        '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' => '-',
-                            'buttonLabelClass' => 'hidden',
-//                        'browseIcon' => '<i class="glyphicon glyphicon-picture 12345"></i>',
-                            'fileActionSettings' => ['showUpload' => false],
-                            'maxFileCount' => 10,
-                            'multiple' => true
-                        ],
-                        'model' => $multipleUploadForm,
-                    ]
-                ],
                 [
                     'name' => 'images_row',
                     'type' => BaseColumn::TYPE_STATIC,
@@ -252,58 +213,93 @@ JS
 //                    'style' => 'width: 70px;',
                     ]
                 ],
+                [
+                    'name' => 'imageFiles',
+                    'title' => 'Фотографии: jpg и png',
+                    'type' => FileInput::className(),
+                    'options' => [
+                        'options' => [
+                            'multiple' => true,
+                            'accept' => 'image/*',
+                            'name' => 'image_name',
+                            'capture' => '',
+                            'class' => 'file'
+                        ],
+                        'pluginOptions' => [
+                            'showPreview' => false,
+                            'showCaption' => true,
+                            'showRemove' => true,
+                            'showUpload' => false,
+                            'overwriteInitial' => true,
+                            'browseIcon' => '+',
+                            'cancelIcon' => 'x',
+                            'removeIcon' => '-',
+                            'buttonLabelClass' => 'hidden',
+                            'fileActionSettings' => ['showUpload' => false],
+                            'maxFileCount' => 10,
+                            'multiple' => true
+                        ],
+                        'model' => $multipleUploadForm,
+                    ],
+                ],
                 [
                     'name' => 'videoFiles',
                     'title' => 'Видео: mp4, mov, avi',
                     'type' => FileInput::className(),
-                    'value' => function ($data) {
-                        if (!$data || !isset($data['id'])) return null;
+                    'value' => function ($row) {
+                        if (!isset($row['id'])) return null;
 
                         $file = Files::findOne([
                             'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
-                            'entity_id' => $data['id']
+                            'entity_id' => $row['id']
                         ]);
 
-                        return $file ? $file->url : null;  // Return just the URL string
+                        return $file ? $file->url : null;
                     },
-                    'options' => [
-                        'options' => [
-                            'multiple' => false,
-                            'accept' => 'video/*',
-                            'name' => 'video_name'
-                        ],
-                        'pluginOptions' => [
-                            'showPreview' => true,
-                            'showCaption' => true,
-                            'showRemove' => true,
-                            'showUpload' => true,
-                            'previewFileType' => 'video',
-                            'allowedFileTypes' => ['video'],
-                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                            '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 ? [[
+                    'columnOptions' => function ($rowModel, $index, $context) {
+                        $file = null;
+                        $initialPreview = [];
+                        $initialPreviewConfig = [];
+
+                        if (isset($rowModel['id'])) {
+                            $file = Files::findOne([
+                                'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                                'entity_id' => $rowModel['id']
+                            ]);
+
+                            if ($file) {
+                                $initialPreview = [$file->url];
+                                $initialPreviewConfig = [[
                                     'type' => 'video',
                                     'caption' => basename($file->url),
-                                    'url' => Url::to(['delete-video', 'id' => $data['id']])
-                                ]] : [];
+                                    'url' => \yii\helpers\Url::to(['delete-video', 'id' => $rowModel['id']]),
+                                ]];
                             }
-                        ],
-                    ],
+                        }
+
+                        return [
+                            'options' => [
+                                'multiple' => false,
+                                'accept' => 'video/*',
+                                'name' => 'video_name'
+                            ],
+                            'pluginOptions' => [
+                                'showPreview' => true,
+                                'showCaption' => true,
+                                'showRemove' => true,
+                                'showUpload' => true,
+                                'previewFileType' => 'video',
+                                'allowedFileTypes' => ['video'],
+                                'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+                                'maxFileSize' => 10240,
+                                'initialPreview' => $initialPreview,
+                                'initialPreviewAsData' => true,
+                                'initialPreviewConfig' => $initialPreviewConfig,
+                            ],
+                        ];
+                    },
                 ],
+
                 [
                     'name' => 'comment',
                     'type' => 'textInput',