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

index 66825fe5785920027349e040ae3960e6410ab949..8ca58128806b399e06b6b57749fda2d13ad687ad 100644 (file)
@@ -175,72 +175,71 @@ JS
 //                'items' => [0,1],
                 ],
                 [
-                    'name' => 'video_row',
+                    'name' => 'images_row',
                     'type' => BaseColumn::TYPE_STATIC,
                     'value' => function ($data) {
+//                    $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp);
                         if (!empty($data['id'])) {
                             $query = WriteOffsProductsErp::find()
                                 ->andWhere([
                                     'write_offs_products_erp.id' => $data['id'],
                                     'write_offs_products_erp.active_product' => 1,
                                 ]);
-                            $query->joinWith(['videosWriteOffsErp']); // связанная связь для видео
 
-                            $models = $query->all();
-                            $videoList = [];
-                            foreach ($models as $item) {
-                                // Предположим, getVideosList возвращает массив html тегов видео или ссылок
-                                $videoList = WriteOffsErp::getVideosList($item->videosWriteOffsErp, false);
+
+                            $query->joinWith(['imagesWriteOffsErp']);
+
+                            $action = $query->createCommand()->getRawSql();
+
+                            $modelWriteOffsProductsErp = $query->All();
+                            $productImagesList = [];
+                            $forWidget = false;
+                            foreach ($modelWriteOffsProductsErp as $item) {
+                                $productImagesList = WriteOffsErp::getImagesList($item->imagesWriteOffsErp, $forWidget);
                             }
-                            if (!empty($videoList)) {
-                                return implode('', $videoList);
+                            if (!empty($productImagesList)) {
+//                            $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
+                                if ($forWidget) {
+                                    $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
+                                } else {
+                                    $dataTable = implode('', $productImagesList);
+                                }
                             }
                         }
-                        return '';
+                        $test = 33;
+                        return $dataTable ?? '';
                     },
                     'headerOptions' => [
-                        //'style' => 'width: 150px;', // при необходимости задайте ширину
-                    ],
+//                    'style' => 'width: 70px;',
+                    ]
                 ],
                 [
-                    'name' => 'videoFiles',
-                    'title' => 'Ð\92идео: mp4, mov, avi',
+                    'name' => 'imageFiles',
+                    'title' => 'ФоÑ\82огÑ\80аÑ\84ии: jpg Ð¸ png',
                     'type' => FileInput::className(),
                     'options' => [
                         'options' => [
-                            'multiple' => false,
-                            'accept' => 'video/*',
-                            'name' => 'video_name',
-                            'class' => 'file',
+                            'multiple' => true,
+                            'accept' => 'image/*',
+                            'name' => 'image_name',
+                            'capture' => '',
+                            'class' => 'file'
                         ],
                         'pluginOptions' => [
-                            'showPreview' => true,
+                            'showPreview' => false,
                             'showCaption' => true,
                             'showRemove' => true,
                             'showUpload' => false,
-                            'previewFileType' => 'video',
-                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                            'maxFileSize' => 10240,
-                            'previewSettings' => [
-                                'video' => ['width' => '120px', 'height' => 'auto'],
-                            ],
-                            'browseLabel' => '+',
-                            'removeLabel' => '-',
-                            'cancelLabel' => 'x',
-                            'layoutTemplates' => [
-                                'actions' => '<div class="file-actions">{remove} {upload} {cancel}</div>',
-                                'actionUpload' => '<button type="button" title="{uploadTitle}" class="kv-file-upload {uploadClass}" style="margin-left:5px">{uploadIcon}</button>',
-                                'actionRemove' => '<button type="button" title="{removeTitle}" class="kv-file-remove {removeClass}">{removeIcon}</button>',
-                                'actionCancel' => '<button type="button" title="{cancelTitle}" class="kv-file-cancel {cancelClass}">{cancelIcon}</button>',
-                            ],
-                            'fileActionSettings' => [
-                                'showUpload' => false,
-                                'showRemove' => true,
-                                'showZoom' => false,
-                                'showDrag' => false,
-                            ],
+                            'overwriteInitial' => true,
+                            'browseIcon' => '+',
+                            'cancelIcon' => 'x',
+                            'removeIcon' => '-',
+                            'buttonLabelClass' => 'hidden',
+                            'fileActionSettings' => ['showUpload' => false],
+                            'maxFileCount' => 10,
+                            'multiple' => true
                         ],
-                        'model' => $multipleUploadForm, // модель загрузки
+                        'model' => $multipleUploadForm,
                     ],
                 ],
                 [
@@ -259,7 +258,6 @@ JS
                     },
                     'columnOptions' => function ($rowModel, $index, $context) {
                         $file = null;
-                        $initialPreview = [];
                         $initialPreviewConfig = [];
 
                         if (isset($rowModel['id'])) {
@@ -269,12 +267,9 @@ JS
                             ]);
 
                             if ($file) {
-                                $initialPreview = [$file->url];
                                 $initialPreviewConfig = [[
-                                    'type' => 'video',
                                     'caption' => basename($file->url),
                                     'url' => \yii\helpers\Url::to(['delete-video', 'id' => $rowModel['id']]),
-                                    // Убрал confirm и метод, можно добавить при необходимости
                                 ]];
                             }
                         }
@@ -285,23 +280,16 @@ JS
                                 'multiple' => false,
                                 'accept' => 'video/*',
                                 'name' => 'video_name',
-                                'class' => 'file', // как у фото
+                                'class' => 'file',
                             ],
                             'pluginOptions' => [
-                                'showPreview' => true,
-                                'showCaption' => true,
+                                'showPreview' => false,           // отключаем превью видео
+                                'showCaption' => true,            // показываем название файла
                                 'showRemove' => true,
                                 'showUpload' => true,
-                                'previewFileType' => 'video',
-                                'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                                'maxFileSize' => 10240,
-                                'initialPreview' => $initialPreview,
-                                'initialPreviewAsData' => true,
+                                'initialPreview' => [],            // без превью
+                                'initialPreviewAsData' => false,  // без превью как данные
                                 'initialPreviewConfig' => $initialPreviewConfig,
-                                // вот ключевые опции:
-                                'previewSettings' => [
-                                    'video' => ['width' => '120px', 'height' => 'auto'],
-                                ],
                                 'browseLabel' => '+',
                                 'removeLabel' => '-',
                                 'cancelLabel' => 'x',