From: marina Date: Tue, 27 May 2025 06:30:25 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=2f9878d611c495ab69046bfad425dd7a9782ac49;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 385862e0..8b1b269a 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -174,6 +174,51 @@ JS ], // 'items' => [0,1], ], + [ + 'name' => 'imageFiles', + 'title' => 'Фотографии: jpg и png', + 'type' => FileInput::className(), + 'options' => [ + 'options' => [ + 'multiple' => true, + 'accept' => 'image/*', + 'name' => 'image_name', + 'capture' => '', + 'class' => 'file', + 'required' => true, + ], + '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), +// ]] : []; +// }, + 'browseIcon' => '+', + 'cancelIcon' => 'x', + 'removeIcon' => '-', + 'buttonLabelClass' => 'hidden', +// 'browseIcon' => '', + 'fileActionSettings' => ['showUpload' => false], + 'maxFileCount' => 10, + 'multiple' => true + ], + 'model' => $multipleUploadForm, + ], + 'columnOptions' => [ + 'class' => 'custom_css_class_file_input' + ] + ], [ 'name' => 'images_row', 'type' => BaseColumn::TYPE_STATIC, @@ -214,111 +259,54 @@ JS ] ], [ - 'name' => 'videoFiles', - 'title' => 'Видео: mp4, mov, avi', - 'type' => FileInput::class, - 'options' => [ - 'options' => [ - 'multiple' => false, - 'accept' => 'video/*', - 'name' => 'video_name', - ], - 'pluginOptions' => [ - 'showPreview' => true, - 'showCaption' => false, // 👈 убираем надпись "1 file selected" - 'showRemove' => true, - 'showUpload' => false, - 'browseIcon' => '+', // 👈 как у фото - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', // 👈 убираем текст на кнопке - 'fileActionSettings' => [ - 'showUpload' => false - ], - 'previewFileType' => '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]), - ]] : [], - ] - ] -], - [ 'name' => 'videoFiles', 'title' => 'Видео: mp4, mov, avi', - 'type' => FileInput::className(), - 'value' => function ($row) { - if (!isset($row['id'])) return null; - - $file = Files::findOne([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $row['id'] - ]); - - return $file ? $file->url : null; - }, - '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' => \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, + 'type' => FileInput::class, + 'options' => [ + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name', + ], + 'pluginOptions' => [ + 'showPreview' => true, + 'showCaption' => false, // 👈 убираем надпись "1 file selected" + 'showRemove' => true, + 'showUpload' => false, + 'browseIcon' => '+', // 👈 как у фото + 'cancelIcon' => 'x', + 'removeIcon' => '-', + 'buttonLabelClass' => 'hidden', // 👈 убираем текст на кнопке + 'fileActionSettings' => [ + 'showUpload' => false ], - ]; - }, + 'previewFileType' => '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]), + ]] : [], + ] + ] ], [ 'name' => 'comment',