From cd245e4eda53e9dbb3899faa204d3d1d6e346e43 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 27 May 2025 09:42:01 +0300 Subject: [PATCH] ERP-417 --- erp24/views/write_offs_erp/_form.php | 102 ++++++++++++--------------- 1 file changed, 45 insertions(+), 57 deletions(-) diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 66825fe5..8ca58128 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -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' => 'Видео: mp4, mov, avi', + 'name' => 'imageFiles', + 'title' => 'Фотографии: 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' => '
{remove} {upload} {cancel}
', - 'actionUpload' => '', - 'actionRemove' => '', - 'actionCancel' => '', - ], - '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', -- 2.39.5